phonebookui/Phonebook2/USIMExtension/src/TPsu2SimCopyResults.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Phonebook 2 SIM copy results.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "TPsu2SimCopyResults.h"
       
    21 
       
    22 // Phonebook 2
       
    23 #include <Pbk2USimUIRes.rsg>
       
    24 #include <Pbk2Commands.rsg>
       
    25 
       
    26 // System includes
       
    27 #include <StringLoader.h>
       
    28 #include <aknnotewrappers.h>
       
    29 
       
    30 /// Unnamed namespace for local definitions
       
    31 namespace {
       
    32 
       
    33 const TInt KZeroContacts( 0 );
       
    34 const TInt KOneContact( 1 );
       
    35 const TInt KGranularity( 2 );
       
    36 
       
    37 } /// namespace
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // TPsu2SimCopyResults::TPsu2SimCopyResults
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 TPsu2SimCopyResults::TPsu2SimCopyResults()
       
    44     {
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // TPsu2SimCopyResults::TPsu2SimCopyResults
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 TPsu2SimCopyResults::TPsu2SimCopyResults( TInt aCopied, TInt aTotal ):
       
    52         iCopied( aCopied ), iNotCopied( aTotal - aCopied )
       
    53     {
       
    54     }
       
    55 
       
    56 // --------------------------------------------------------------------------
       
    57 // TPsu2SimCopyResults::TPsu2SimCopyResults
       
    58 // --------------------------------------------------------------------------
       
    59 //
       
    60 TPsu2SimCopyResults::TPsu2SimCopyResults( TInt aCopied, const TDesC& aName ):
       
    61         iCopied( aCopied ), iName( aName )
       
    62     {
       
    63     }
       
    64 
       
    65 // --------------------------------------------------------------------------
       
    66 // TPsu2SimCopyResults::ShowNoteL
       
    67 // --------------------------------------------------------------------------
       
    68 //
       
    69 void TPsu2SimCopyResults::ShowNoteL()
       
    70     {
       
    71     if ( iName.Length() == 0 )
       
    72         {
       
    73         // Multiple contacts were marked to be copied
       
    74         ShowMultipleCopyNoteL();
       
    75         }
       
    76     else
       
    77         {
       
    78         // Only one contact was marked to be copied
       
    79         ShowSingleCopyNoteL();
       
    80         }
       
    81     }
       
    82 
       
    83 // --------------------------------------------------------------------------
       
    84 // TPsu2SimCopyResults::ShowErrorNoteL
       
    85 // --------------------------------------------------------------------------
       
    86 //
       
    87 void TPsu2SimCopyResults::ShowErrorNoteL()
       
    88     {
       
    89     HBufC* prompt = StringLoader::LoadLC( R_QTN_PBCOP_NOTE_COPY_NOT_WORK );
       
    90     CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue );
       
    91     note->ExecuteLD( *prompt );
       
    92     CleanupStack::PopAndDestroy( prompt );
       
    93     }
       
    94 
       
    95 // --------------------------------------------------------------------------
       
    96 // TPsu2SimCopyResults::ShowPartlyCopiedNoteL
       
    97 // --------------------------------------------------------------------------
       
    98 //
       
    99 void TPsu2SimCopyResults::ShowPartlyCopiedNoteL()
       
   100     {
       
   101     CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue );
       
   102     HBufC* prompt = NULL;
       
   103 
       
   104     if ( iName.Length() == 0 )
       
   105         {
       
   106         // For multiple contacts copy
       
   107         prompt = StringLoader::LoadLC
       
   108             ( R_QTN_PBCOP_NOTE_ENTRIES_COPIED_PARTLY );
       
   109         }
       
   110     else
       
   111         {
       
   112         // For one contact copy
       
   113         prompt = StringLoader::LoadLC
       
   114             ( R_QTN_PBCOP_NOTE_ENTRY_COPIED_PARTLY );
       
   115         }
       
   116     dlg->ExecuteLD( *prompt );
       
   117 
       
   118     CleanupStack::PopAndDestroy( prompt );
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // TPsu2SimCopyResults::ShowSingleCopyNoteL
       
   123 // --------------------------------------------------------------------------
       
   124 //
       
   125 inline void TPsu2SimCopyResults::ShowSingleCopyNoteL()
       
   126     {
       
   127     HBufC* prompt = NULL;
       
   128     CAknResourceNoteDialog* dlg = NULL;
       
   129     if ( iCopied > 0 )
       
   130         {
       
   131         prompt = StringLoader::LoadLC
       
   132             ( R_QTN_PBCOP_NOTE_CONTACT_COPIED_PB2, iName );
       
   133         dlg = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   134         }
       
   135     else
       
   136         {
       
   137         prompt = StringLoader::LoadLC
       
   138             ( R_QTN_PBCOP_NOTE_ENTRY_NOT_COPIED, iName );
       
   139         dlg = new ( ELeave ) CAknInformationNote( ETrue );
       
   140         }
       
   141     dlg->ExecuteLD( *prompt );
       
   142     CleanupStack::PopAndDestroy( prompt );
       
   143     }
       
   144 
       
   145 // --------------------------------------------------------------------------
       
   146 // TPsu2SimCopyResults::ShowMultipleCopyNoteL
       
   147 // --------------------------------------------------------------------------
       
   148 //
       
   149 inline void TPsu2SimCopyResults::ShowMultipleCopyNoteL()
       
   150     {
       
   151     if ( iNotCopied == KZeroContacts )
       
   152         {
       
   153         HBufC* prompt = StringLoader::LoadLC
       
   154             ( R_QTN_PBCOP_NOTE_N_ENTRY_COPY_PB, iCopied );
       
   155 
       
   156         CAknConfirmationNote* dlg =
       
   157             new ( ELeave ) CAknConfirmationNote( ETrue );
       
   158         dlg->ExecuteLD( *prompt );
       
   159 
       
   160         CleanupStack::PopAndDestroy( prompt );
       
   161         }
       
   162     else
       
   163         {
       
   164         HBufC* errorPrompt = NULL;
       
   165         if ( iCopied == KOneContact && iNotCopied == KOneContact )
       
   166             {
       
   167             errorPrompt = StringLoader::LoadLC
       
   168                 ( R_QTN_PBCOP_INFO_ONE_OK_ONE_NOT );
       
   169             }
       
   170         else if ( iCopied == KOneContact && iNotCopied > KOneContact )
       
   171             {
       
   172             errorPrompt = StringLoader::LoadLC
       
   173                 ( R_QTN_PBCOP_INFO_ONE_OK_N_NOT, iNotCopied );
       
   174             }
       
   175         else if ( ( iCopied == KZeroContacts || iCopied > KOneContact ) &&
       
   176                   ( iNotCopied == KOneContact ) )
       
   177             {
       
   178             errorPrompt = StringLoader::LoadLC
       
   179                 ( R_QTN_PBCOP_INFO_N_OK_ONE_NOT, iCopied );
       
   180             }
       
   181         else if ( ( iCopied == KZeroContacts || iCopied > KOneContact ) &&
       
   182                   ( iNotCopied == KZeroContacts || iNotCopied > KOneContact ) )
       
   183             {
       
   184             CArrayFixFlat<TInt>* array =
       
   185                 new( ELeave ) CArrayFixFlat<TInt>( KGranularity );
       
   186             CleanupStack::PushL( array );
       
   187 
       
   188             array->AppendL( iCopied );
       
   189             array->AppendL( iNotCopied );
       
   190             errorPrompt = StringLoader::LoadL
       
   191                 ( R_QTN_PBCOP_INFO_N_OK_N_NOT, *array );
       
   192 
       
   193             CleanupStack::PopAndDestroy( array );
       
   194             CleanupStack::PushL( errorPrompt );
       
   195             }
       
   196 
       
   197         if ( errorPrompt )
       
   198             {
       
   199 
       
   200 	        CAknInformationNote* dlg =
       
   201 	            new ( ELeave ) CAknInformationNote( ETrue );
       
   202 	        dlg->ExecuteLD( *errorPrompt );
       
   203 	        CleanupStack::PopAndDestroy( errorPrompt );
       
   204             }
       
   205         }
       
   206     }
       
   207 //  End of File