phonebookui/Phonebook/View/src/CPbkDeleteContactQuery.cpp
changeset 0 e686773b3f54
child 68 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *           Methods for Phonebook contact deletion query
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkDeleteContactQuery.h"
       
    22 #include <PbkView.rsg>
       
    23 #include <StringLoader.h>
       
    24 #include <CPbkContactItem.h>
       
    25 #include <CPbkContactEngine.h>
       
    26 
       
    27 namespace {
       
    28 
       
    29 // LOCAL CONSTANTS
       
    30 enum TPanicCode
       
    31     {
       
    32     CPbkDeleteContactQuery_RunLD =1
       
    33     };
       
    34 
       
    35 // ==================== LOCAL FUNCTIONS ====================
       
    36 
       
    37 #ifdef _DEBUG
       
    38 
       
    39 void Panic(TPanicCode aReason)
       
    40     {
       
    41     _LIT(KPanicText, "CPbkDeleteContactQuery");
       
    42     User::Panic(KPanicText,aReason);
       
    43     }
       
    44 
       
    45 #endif
       
    46 
       
    47 }  // namespace
       
    48 
       
    49 
       
    50 // ==================== MEMBER FUNCTIONS ====================
       
    51 
       
    52 inline CPbkDeleteContactQuery::CPbkDeleteContactQuery()
       
    53     {
       
    54     }
       
    55 
       
    56 EXPORT_C CPbkDeleteContactQuery* CPbkDeleteContactQuery::NewLC()
       
    57     {
       
    58     CPbkDeleteContactQuery* self = new(ELeave) CPbkDeleteContactQuery;
       
    59     self->PrepareLC(R_PBK_DELETE_QUERY);
       
    60     return self;
       
    61     }
       
    62 
       
    63 CPbkDeleteContactQuery::~CPbkDeleteContactQuery()
       
    64     {
       
    65     }
       
    66 
       
    67 EXPORT_C TInt CPbkDeleteContactQuery::RunLD(const CPbkContactItem& aContact)
       
    68     {
       
    69     CreatePromptL(aContact);
       
    70     return CAknQueryDialog::RunLD();
       
    71     }
       
    72 
       
    73 EXPORT_C TInt CPbkDeleteContactQuery::RunLD
       
    74         (CPbkContactEngine& aEngine, TContactItemId aContactId)
       
    75     {
       
    76     CPbkContactItem* item = aEngine.ReadContactLC(aContactId);
       
    77     CreatePromptL(*item);
       
    78     CleanupStack::PopAndDestroy(item);
       
    79     return CAknQueryDialog::RunLD();
       
    80     }
       
    81 
       
    82 EXPORT_C TInt CPbkDeleteContactQuery::RunLD
       
    83         (CPbkContactEngine& aEngine, const CContactIdArray& aContactIds)
       
    84     {
       
    85     const TInt count = aContactIds.Count();
       
    86 
       
    87     __ASSERT_DEBUG(count >= 0, Panic(CPbkDeleteContactQuery_RunLD));
       
    88 
       
    89     if (count == 0)
       
    90         {
       
    91         return 0;
       
    92         }
       
    93     else if (count == 1)
       
    94         {
       
    95         return RunLD(aEngine, aContactIds[0]);
       
    96         }
       
    97     else 
       
    98         {
       
    99         CreatePromptL(aContactIds);
       
   100         return CAknQueryDialog::RunLD();
       
   101         }
       
   102     }
       
   103 
       
   104 void CPbkDeleteContactQuery::CreatePromptL(const CPbkContactItem& aContact)
       
   105     {
       
   106     HBufC* name = aContact.GetContactTitleL();
       
   107     CleanupStack::PushL(name);
       
   108     HBufC* prompt = StringLoader::LoadLC(R_QTN_QUERY_COMMON_CONF_DELETE, *name);
       
   109     CAknQueryDialog::SetPromptL(*prompt);
       
   110     CleanupStack::PopAndDestroy(2, name);
       
   111     }
       
   112 
       
   113 void CPbkDeleteContactQuery::CreatePromptL(const CContactIdArray& aContactIds)
       
   114     {
       
   115     HBufC* prompt = StringLoader::LoadLC
       
   116         (R_QTN_PHOB_QUERY_DELETE_N_ENTRIES, aContactIds.Count());
       
   117     CAknQueryDialog::SetPromptL(*prompt);
       
   118     CleanupStack::PopAndDestroy(prompt);
       
   119     }
       
   120 
       
   121 // End of File