wvuing/ImUtils/Src/IMNoteMapper.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Utility class for mapping error codes to notes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "IMNoteMapper.h"
       
    21 #include "IMDialogUtils.h"
       
    22 #include "ChatDebugPrint.h"
       
    23 #include <stringloader.h>
       
    24 #include <ChatNG.rsg>
       
    25 #include <eikenv.h>
       
    26 #include "ImpsCSPAllErrors.h"
       
    27 #include "PublicEngineDefinitions.h"
       
    28 #include "imutils.h"
       
    29 
       
    30 // ---------------------------------------------------------
       
    31 // IMNoteMapper::ShowNoteL
       
    32 // (other items were commented in a header).
       
    33 // ---------------------------------------------------------
       
    34 //
       
    35 EXPORT_C void IMNoteMapper::ShowNoteL( const TInt aErrorCode, const TDesC& aAdditionalData )
       
    36     {
       
    37     TBool ignoreAdditionalData( EFalse ); // Some logical strings are without parameters...
       
    38     TBool errorNote( ETrue );
       
    39     TBool defaultNote( EFalse );
       
    40     TInt resourceID( 0 );
       
    41     TBool confirmationNote( EFalse );
       
    42     TBool softkeyOk( EFalse );
       
    43 
       
    44     switch ( aErrorCode )
       
    45         {
       
    46         case KErrNoMemory:
       
    47             {
       
    48             errorNote = ETrue;
       
    49             resourceID = R_CHAT_CEDITOR_MEMLO;
       
    50             ignoreAdditionalData = ETrue;
       
    51             break;
       
    52             }
       
    53         case KErrDiskFull:
       
    54             {
       
    55             errorNote = ETrue;
       
    56             resourceID = R_CHAT_CEDITOR_MEMFULL;
       
    57             ignoreAdditionalData = ETrue;
       
    58             break;
       
    59             }
       
    60 
       
    61         // flowthrough
       
    62         case ECSPPartiallySuccessful:
       
    63         case ECSPSuccessful:
       
    64         case KErrNone:
       
    65             {
       
    66             CHAT_DP_TXT( "IMNoteMapper::ShowNoteL - not an error" );
       
    67             return; // don't show any notes
       
    68             }
       
    69 
       
    70         case ECSPRecipientBlockedSender: // recipient has blocked sender
       
    71             {
       
    72             resourceID = R_CHAT_RECIPIENT_BLOCKED_MESSAGES;
       
    73             ignoreAdditionalData = EFalse;
       
    74             errorNote = ETrue;
       
    75             softkeyOk = ETrue;
       
    76             break;
       
    77             }
       
    78 
       
    79         // flowthrough
       
    80         case ESearchNotSupported:
       
    81         case ECSPNotSupported: // Service not supported
       
    82         case ECSPServiceNotAgreed: // Service not agreed
       
    83             {
       
    84             resourceID = R_CHAT_ERROR_SERVICE_ERR;
       
    85             ignoreAdditionalData = ETrue;
       
    86             break;
       
    87             }
       
    88 
       
    89         case ECSPWrongPassword: // Invalid password
       
    90             {
       
    91             resourceID = R_CHAT_LOGIN_PASSER_NOTE;
       
    92             ignoreAdditionalData = ETrue;
       
    93             break;
       
    94             }
       
    95 
       
    96         case ECSPCannotDeliver: // Unable to deliver
       
    97             {
       
    98             resourceID = R_CHAT_INVITE_SEND_ERROR;
       
    99             ignoreAdditionalData = ETrue;
       
   100             break;
       
   101             }
       
   102 
       
   103         // flowthrough
       
   104         case ECSPServiceUnavailable: // Service unavailable
       
   105         case ECSPMessageQueueFull: // Message queue is full
       
   106             {
       
   107             resourceID = R_CHAT_ERROR_SERV_BUSY;
       
   108             ignoreAdditionalData = ETrue;
       
   109             break;
       
   110             }
       
   111 
       
   112         case ECSPUnsupportedVersion: // Version not supported
       
   113             {
       
   114             resourceID = R_CHAT_ERROR_GEN_ERROR;
       
   115             ignoreAdditionalData = ETrue;
       
   116             break;
       
   117             }
       
   118         case ECSPInvalidSearchId: // Invalid search id. Search timed out.
       
   119         case ECSPSearchTimeout: // Search timed out
       
   120             {
       
   121             resourceID = R_CHAT_ERROR_SEARCH_FAIL;
       
   122             ignoreAdditionalData = ETrue;
       
   123             break;
       
   124             }
       
   125 
       
   126         // flowthrough
       
   127         case ECSPTooManyHits: // Too many hits
       
   128         case ECSPTooBroadSearchCriteria: // Too broad search criteria
       
   129             {
       
   130             errorNote = EFalse;
       
   131             resourceID = R_CHAT_INOTE_TOO_MANY_HITS;
       
   132             ignoreAdditionalData = ETrue;
       
   133             break;
       
   134             }
       
   135 
       
   136         // flowthrough
       
   137         case KErrTimedOut: //Time out for requests
       
   138         case ECSPSessionExpired: // Session expired
       
   139         case ECSPForcedLogout: // Forced logout
       
   140             {
       
   141             IMDialogUtils::DisplayQueryDialogL( R_CHAT_CONERROR_NOTE );
       
   142             break;
       
   143             }
       
   144 
       
   145         case ECSPGroupDoesNotExist: // Group does not exist
       
   146             {
       
   147             resourceID = R_CHAT_ERROR_NO_GROUP;
       
   148             ignoreAdditionalData = ETrue;
       
   149             break;
       
   150             }
       
   151 
       
   152         case ECSPInvalidParameter + Imps_ERROR_BASE:    // Flowthrough
       
   153         case ECSPGroupDoesNotExist + Imps_ERROR_BASE:
       
   154             {
       
   155             // Manually entered group id was not found from server
       
   156             resourceID = R_CHAT_INOTE_CNOTFOUND;
       
   157             ignoreAdditionalData = ETrue;
       
   158             break;
       
   159             }
       
   160 
       
   161         // flowthrough
       
   162         case ECSPGroupNotJoined: // Group is not joined
       
   163 
       
   164             //start
       
   165         case ECSPCannotJoinRejected: // Rejected
       
   166             //end
       
   167         case ECSPNotAGroupMember: // Access removed
       
   168         case ECSPGroupIsRestricted: // Kicked out
       
   169             {
       
   170             errorNote = EFalse;
       
   171             resourceID = R_CHAT_INOTE_KICKED;
       
   172             ignoreAdditionalData = ETrue;
       
   173             break;
       
   174             }
       
   175 
       
   176         case ECSPScreennameInUse: // Screen name already in use
       
   177             {
       
   178             errorNote = EFalse;
       
   179             resourceID = R_CHAT_JOIN_SAME_N;
       
   180             ignoreAdditionalData = ETrue;
       
   181             break;
       
   182             }
       
   183 
       
   184         // flowthrough
       
   185         case ECSPMaxNumberOfGroupsForUser: // The maximum number of groups has been reached for the user
       
   186         case ECSPMaxNumberOfGroupsForServer: // The maximum number of groups has been reached for the server
       
   187             {
       
   188             errorNote = EFalse;
       
   189             resourceID = R_CHAT_INOTE_GROUP_FULL;
       
   190             ignoreAdditionalData = ETrue;
       
   191             break;
       
   192             }
       
   193 
       
   194         case ECSPInsufficientGroupPrivileges: // Insufficient group privileges
       
   195             {
       
   196             resourceID = R_CHAT_JOIN_NOTE_ERROR;
       
   197             ignoreAdditionalData = ETrue;
       
   198             break;
       
   199             }
       
   200 
       
   201         case ECSPMaxNumberOfJoinedUsers: // The maximum number of joined users has been reached
       
   202             {
       
   203             errorNote = EFalse;
       
   204             resourceID = R_CHAT_INOTE_CHAT_FULL;
       
   205             ignoreAdditionalData = ETrue;
       
   206             break;
       
   207             }
       
   208 
       
   209         // flowthrough
       
   210         case ECSPDomainNotSupported: // Domain not supported
       
   211         case ECSPRecipientNotLoggedIn: // Message recipient not logged in
       
   212             {
       
   213             errorNote = ETrue;
       
   214             resourceID = R_CHAT_ERROR_NOT_REACH;
       
   215             break;
       
   216             }
       
   217 
       
   218         case ECSPUnknownUserId: // Unknown user
       
   219             {
       
   220             errorNote = ETrue;
       
   221             resourceID = R_CHAT_ERROR_WRONG_WVID;
       
   222             if ( aAdditionalData == KNullDesC )
       
   223                 {
       
   224                 resourceID = R_CHAT_SERVERCONT_IDS_EXIST_SERVER;
       
   225                 ignoreAdditionalData = ETrue;
       
   226                 }
       
   227             break;
       
   228             }
       
   229 
       
   230         case ECSPUnknownUserId + Imps_ERROR_BASE:
       
   231             {
       
   232             // User has started conversation by entering user id
       
   233             // manually -> user not found from server
       
   234             errorNote = ETrue;
       
   235             resourceID = R_CHAT_INOTE_NAME_NOTFOUND;
       
   236             break;
       
   237             }
       
   238 
       
   239         case EServerContactListFull:    // contact list on the server is full
       
   240             {
       
   241             errorNote = ETrue;
       
   242             resourceID = R_QTN_CHAT_SERVER_FULL;
       
   243             break;
       
   244             }
       
   245 
       
   246         case ECorruptedContent:
       
   247             {
       
   248             confirmationNote = ETrue;
       
   249             resourceID = R_QTN_MMS_UPLOAD_INFO_CORRUPTED;
       
   250             ignoreAdditionalData = ETrue;
       
   251             break;
       
   252             }
       
   253 
       
   254         case EGeneralServerError:   // flowthrough
       
   255         default: // Unknown error -> show general note
       
   256             {
       
   257             defaultNote = ETrue;
       
   258             errorNote = ETrue;
       
   259             ignoreAdditionalData = ETrue;
       
   260             resourceID = R_CHAT_ERROR_GEN_ERROR;
       
   261             break;
       
   262             }
       
   263         }
       
   264 
       
   265     if ( resourceID != 0 )
       
   266         {
       
   267         if ( confirmationNote )
       
   268             {
       
   269             IMDialogUtils::DisplayQueryDialogL( resourceID );
       
   270             }
       
   271         else
       
   272             {
       
   273             HBufC* prompt = NULL;
       
   274 
       
   275             if ( aAdditionalData == KNullDesC || defaultNote || ignoreAdditionalData )
       
   276                 {
       
   277                 prompt = CEikonEnv::Static()->AllocReadResourceLC( resourceID );
       
   278                 }
       
   279             else
       
   280                 {
       
   281                 prompt = StringLoader::LoadLC( resourceID, aAdditionalData );
       
   282                 }
       
   283 
       
   284             if ( errorNote )
       
   285                 {
       
   286                 IMDialogUtils::DisplayErrorNoteL( *prompt, softkeyOk );
       
   287                 }
       
   288             else
       
   289                 {
       
   290                 IMDialogUtils::DisplayNoteDialogL( *prompt );
       
   291                 }
       
   292 
       
   293             CleanupStack::PopAndDestroy( prompt );
       
   294             }
       
   295         }
       
   296     }
       
   297 
       
   298 //  End of File