phonebookui/Phonebook2/ServerApplication/src/TPbk2AssignNoteService.cpp
branchRCL_3
changeset 63 f4a778e096c2
parent 0 e686773b3f54
child 68 9da50d567e3c
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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 assign note service.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "TPbk2AssignNoteService.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include <MPbk2ContactNameFormatter.h>
       
    23 #include <CPbk2StorePropertyArray.h>
       
    24 #include <CPbk2StoreProperty.h>
       
    25 #include <Pbk2ServerApp.rsg>
       
    26 #include <Pbk2UIControls.rsg>
       
    27 #include <Pbk2CommonUi.rsg>
       
    28 
       
    29 // Virtual Phonebook
       
    30 #include <MVPbkContactStore.h>
       
    31 #include <MVPbkStoreContact.h>
       
    32 #include <MVPbkContactStoreProperties.h>
       
    33 
       
    34 // System includes
       
    35 #include <aknnotewrappers.h>
       
    36 #include <StringLoader.h>
       
    37 
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // TPbk2AssignNoteService::TPbk2AssignNoteService
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 TPbk2AssignNoteService::TPbk2AssignNoteService()
       
    44     {
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // TPbk2AssignNoteService::ShowInformationNoteL
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 void TPbk2AssignNoteService::ShowInformationNoteL( TInt aResourceId ) const
       
    52     {
       
    53     HBufC* text = StringLoader::LoadLC( aResourceId );
       
    54     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
    55     note->ExecuteLD( *text );
       
    56     CleanupStack::PopAndDestroy( text );
       
    57     }
       
    58 
       
    59 // --------------------------------------------------------------------------
       
    60 // TPbk2AssignNoteService::ShowInformationNoteL
       
    61 // --------------------------------------------------------------------------
       
    62 //
       
    63 void TPbk2AssignNoteService::ShowInformationNoteL
       
    64         ( TInt aResourceId, TVPbkContactStoreUriPtr aStoreUri,
       
    65           const CPbk2StorePropertyArray& aStoreProperties ) const
       
    66     {
       
    67     const CPbk2StoreProperty* storeProperty =
       
    68         aStoreProperties.FindProperty( aStoreUri );
       
    69 
       
    70     TDesC* storeName = NULL;
       
    71 
       
    72     if ( storeProperty )
       
    73         {
       
    74         storeName = const_cast<TDesC*>( &storeProperty->StoreName() );
       
    75         }
       
    76     else
       
    77         {
       
    78         storeName = const_cast<TDesC*>( &aStoreUri.UriDes() );
       
    79         }
       
    80 
       
    81     HBufC* text = StringLoader::LoadLC( aResourceId, *storeName );
       
    82     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
    83     note->ExecuteLD( *text );
       
    84     CleanupStack::PopAndDestroy( text ); //text
       
    85     }
       
    86 
       
    87 // --------------------------------------------------------------------------
       
    88 // TPbk2AssignNoteService::ShowConfirmationNoteL
       
    89 // --------------------------------------------------------------------------
       
    90 //
       
    91 TInt TPbk2AssignNoteService::ShowConfirmationNoteL
       
    92         ( TInt aResourceId, const TDesC& aText ) const
       
    93     {
       
    94     HBufC* text = StringLoader::LoadLC( aResourceId, aText );
       
    95     CAknConfirmationNote* query = new ( ELeave ) CAknConfirmationNote;
       
    96     TInt result = query->ExecuteLD( *text );
       
    97     CleanupStack::PopAndDestroy( text );
       
    98     return result;
       
    99     }
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // TPbk2AssignNoteService::ShowReplaceDetailQueryL
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 TInt TPbk2AssignNoteService::ShowReplaceDetailQueryL
       
   106         ( MPbk2ContactNameFormatter& aContactNameFormatter,
       
   107           MVPbkStoreContact& aStoreContact ) const
       
   108     {
       
   109     HBufC* contactName = aContactNameFormatter.GetContactTitleL
       
   110         ( aStoreContact.Fields(),
       
   111           MPbk2ContactNameFormatter::EPreserveLeadingSpaces );
       
   112     CleanupStack::PushL( contactName );
       
   113 
       
   114     HBufC* prompt = StringLoader::LoadLC
       
   115         ( R_QTN_PHOB_NOTE_REPLACE_DETAIL, *contactName );
       
   116 
       
   117     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   118     TInt queryResult = dlg->ExecuteLD
       
   119         ( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt );
       
   120 
       
   121     CleanupStack::PopAndDestroy( 2 ); //prompt, contactName
       
   122 
       
   123     return queryResult;
       
   124     }
       
   125 
       
   126 // --------------------------------------------------------------------------
       
   127 // TPbk2AssignNoteService::ShowDetailAddedNoteL
       
   128 // --------------------------------------------------------------------------
       
   129 //
       
   130 void TPbk2AssignNoteService::ShowDetailAddedNoteL( TInt aCount ) const
       
   131     {
       
   132     HBufC* text = NULL;
       
   133     if ( aCount <= 0 )
       
   134         {
       
   135         text = StringLoader::LoadLC( R_QTN_PHOB_NOTE_DETAIL_NOT_ADDED );
       
   136         }
       
   137     else if ( aCount == 1 )
       
   138         {
       
   139         text = StringLoader::LoadLC( R_QTN_PHOB_NOTE_DETAIL_ADDED );
       
   140         }
       
   141     else
       
   142         {
       
   143         text = StringLoader::LoadLC
       
   144             ( R_QTN_PHOB_NOTE_DETAIL_ADDED_TO_N, aCount );
       
   145         }
       
   146 
       
   147     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   148     note->ExecuteLD( *text );
       
   149     CleanupStack::PopAndDestroy( text );
       
   150     }
       
   151 
       
   152 // --------------------------------------------------------------------------
       
   153 // TPbk2AssignNoteService::ShowCanNotAddDetailNoteL
       
   154 // --------------------------------------------------------------------------
       
   155 //
       
   156 void TPbk2AssignNoteService::ShowCanNotAddDetailNoteL
       
   157         ( MPbk2ContactNameFormatter& aContactNameFormatter,
       
   158           MVPbkStoreContact& aStoreContact ) const
       
   159     {
       
   160     HBufC* contactName = aContactNameFormatter.GetContactTitleL
       
   161         ( aStoreContact.Fields(),
       
   162           MPbk2ContactNameFormatter::EPreserveLeadingSpaces );
       
   163     CleanupStack::PushL( contactName );
       
   164 
       
   165     HBufC* text = StringLoader::LoadLC
       
   166         ( R_QTN_PHOB_NOTE_CANNOT_ADD_DETAIL, *contactName );
       
   167     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   168     note->ExecuteLD( *text );
       
   169 
       
   170     CleanupStack::PopAndDestroy( 2 ); // text, contactName
       
   171     }
       
   172 
       
   173 
       
   174 // --------------------------------------------------------------------------
       
   175 // TPbk2AssignNoteService::ShowCreateNewToPhoneQueryL
       
   176 // --------------------------------------------------------------------------
       
   177 //
       
   178 TInt TPbk2AssignNoteService::ShowCreateNewToPhoneQueryL() const
       
   179     {
       
   180     HBufC* prompt = StringLoader::LoadLC
       
   181         ( R_QTN_PHOB_QUERY_CREATE_NEW_TO_STORE );
       
   182 
       
   183     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   184     TInt queryResult = dlg->ExecuteLD
       
   185         ( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt );
       
   186     CleanupStack::PopAndDestroy( prompt );
       
   187 
       
   188     return queryResult;
       
   189     }
       
   190 
       
   191 // --------------------------------------------------------------------------
       
   192 // TPbk2AssignNoteService::ShowStoreFullNoteL
       
   193 // --------------------------------------------------------------------------
       
   194 //
       
   195 void TPbk2AssignNoteService::ShowStoreFullNoteL
       
   196         ( const MVPbkContactStore& aTargetStore,
       
   197           const CPbk2StorePropertyArray& aStoreProperties ) const
       
   198     {
       
   199     // Fetch store name
       
   200     TVPbkContactStoreUriPtr uri = aTargetStore.StoreProperties().Uri();
       
   201 
       
   202     const CPbk2StoreProperty* storeProperty =
       
   203         aStoreProperties.FindProperty( uri );
       
   204 
       
   205     const TDesC* storeName = NULL;
       
   206     if ( storeProperty )
       
   207         {
       
   208         storeName = &storeProperty->StoreName();
       
   209         }
       
   210     else
       
   211         {
       
   212         storeName = &uri.UriDes();
       
   213         }
       
   214 
       
   215     HBufC* prompt = StringLoader::LoadLC
       
   216         ( R_QTN_PHOB_NOTE_STORE_FULL, *storeName );
       
   217     CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue );
       
   218     dlg->ExecuteLD( *prompt );
       
   219     CleanupStack::PopAndDestroy(); // prompt
       
   220     }
       
   221 
       
   222 // End of File