phonebookui/Phonebook/View/src/CPbkAddToGroup.cpp
changeset 0 e686773b3f54
child 21 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 *       Provides methods for UI control of Phonebook's "Add to group".
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkAddToGroup.h"     // This class
       
    22 #include <cntitem.h>            // CContactGroup
       
    23 #include <aknnotewrappers.h>    // AVKON Notes
       
    24 #include <StringLoader.h>       // StringLoader
       
    25 
       
    26 #include <PbkView.rsg>  // Phonebook view dll resource IDs
       
    27 #include "CPbkGroupPopup.h"
       
    28 
       
    29 #include <CPbkContactEngine.h>  // Phonebook engine
       
    30 
       
    31 // ==================== LOCAL FUNCTIONS ====================
       
    32 
       
    33 /// Unnamed namespace for this-file-only helper funtions
       
    34 namespace {
       
    35 
       
    36 #ifdef _DEBUG
       
    37 
       
    38 // LOCAL CONSTANTS AND MACROS
       
    39 enum TPanicCode
       
    40     {
       
    41     EPanicLogic_ExecuteLD = 1
       
    42     };
       
    43 
       
    44 void Panic(TPanicCode aReason)
       
    45     {
       
    46     _LIT(KPanicText, "CPbkAddToGroup");
       
    47     User::Panic(KPanicText, aReason);
       
    48     }
       
    49 
       
    50 #endif // _DEBUG
       
    51 
       
    52 } // namespace
       
    53 
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =======================
       
    56 
       
    57 inline CPbkAddToGroup::CPbkAddToGroup()
       
    58     {
       
    59     }
       
    60 
       
    61 EXPORT_C CPbkAddToGroup* CPbkAddToGroup::NewL()
       
    62     {
       
    63     CPbkAddToGroup* self = new(ELeave) CPbkAddToGroup;
       
    64     return self;
       
    65     }
       
    66 
       
    67 EXPORT_C TContactItemId CPbkAddToGroup::ExecuteLD
       
    68         (CPbkContactEngine& aEngine)
       
    69     {
       
    70     TBool thisDestroyed = EFalse;
       
    71     iDestroyedPtr = &thisDestroyed;
       
    72     CleanupStack::PushL(this);
       
    73 
       
    74     CPbkGroupPopup::TParams params
       
    75         (aEngine.AllGroupsViewL(), 
       
    76         R_AVKON_SOFTKEYS_CANCEL,
       
    77         R_PBK_SOFTKEYS_ASSIGN_CANCEL);
       
    78     params.iPrompt = StringLoader::LoadLC(R_QTN_PHOB_QTL_ADD_TO_GRP);
       
    79     params.iEmptyText = &KNullDesC;
       
    80 
       
    81     iGroupPopup = CPbkGroupPopup::NewL(params);
       
    82     iGroupPopup->ResetWhenDestroyed(&iGroupPopup);
       
    83     const TInt result = iGroupPopup->ExecuteLD();
       
    84     TContactItemId ret = KNullContactId;
       
    85     if (result)
       
    86         {
       
    87         __ASSERT_DEBUG(!thisDestroyed, Panic(EPanicLogic_ExecuteLD));
       
    88         ret = params.iSelectedGroupId;
       
    89         }
       
    90 
       
    91     CleanupStack::PopAndDestroy();  // params.iPrompt
       
    92     if (thisDestroyed)
       
    93         {
       
    94         CleanupStack::Pop(this);
       
    95         }
       
    96     else
       
    97         {
       
    98         CleanupStack::PopAndDestroy(this);
       
    99         }
       
   100     return ret;
       
   101     }
       
   102 
       
   103 CPbkAddToGroup::~CPbkAddToGroup()
       
   104     {
       
   105     if (iDestroyedPtr) 
       
   106         {
       
   107         *iDestroyedPtr = ETrue;
       
   108         }
       
   109     delete iGroupPopup;
       
   110     }
       
   111 
       
   112 //  End of File