phonebookui/Phonebook/App/src/CPbkAiwInterestItemPoc.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 *     Implements Poc AIW interest item functionality.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkAiwInterestItemPoc.h"
       
    22 
       
    23 #include <CPbkContactEngine.h>
       
    24 #include "CPbkPocAddressSelect.h"
       
    25 #include "CPbkCallTypeSelector.h"
       
    26 #include "PbkUid.h"
       
    27 #include <Phonebook.hrh>
       
    28 #include <CPbkAppGlobalsBase.h>
       
    29 #include <MPbkCommand.h>
       
    30 #include <MPbkCommandFactory.h>
       
    31 #include <MenuFilteringFlags.h>
       
    32 #include <MPbkAiwCommandObserver.h>
       
    33 #include <AiwPoCParameters.h>
       
    34 
       
    35 #include <Phonebook.rsg>
       
    36 #include <AiwServiceHandler.h>
       
    37 #include <AiwPoCParameters.hrh>
       
    38 #include <eikmenup.h>
       
    39 
       
    40 
       
    41 // ================= MEMBER FUNCTIONS =======================
       
    42 
       
    43 inline CPbkAiwInterestItemPoc::CPbkAiwInterestItemPoc
       
    44         (CAiwServiceHandler& aServiceHandler,
       
    45         CPbkContactEngine& aEngine) :
       
    46             CPbkAiwInterestItemBase(aServiceHandler),
       
    47             iEngine(aEngine)
       
    48     {
       
    49     }
       
    50 
       
    51 
       
    52 CPbkAiwInterestItemPoc* CPbkAiwInterestItemPoc::NewL(
       
    53         CAiwServiceHandler& aServiceHandler,
       
    54         CPbkContactEngine& aEngine)
       
    55     {
       
    56     CPbkAiwInterestItemPoc* self =
       
    57         new (ELeave) CPbkAiwInterestItemPoc(aServiceHandler, aEngine);
       
    58     CleanupStack::PushL(self);
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop(self);
       
    61     return self;
       
    62     }
       
    63 
       
    64 CPbkAiwInterestItemPoc::~CPbkAiwInterestItemPoc()
       
    65     {
       
    66     delete iSelector;
       
    67     }
       
    68 
       
    69 void CPbkAiwInterestItemPoc::ConstructL()
       
    70     {
       
    71     iSelector = CPbkCallTypeSelector::NewL(iEngine);
       
    72     }
       
    73 
       
    74 TBool CPbkAiwInterestItemPoc::InitMenuPaneL(
       
    75         TInt aResourceId,
       
    76         CEikMenuPane& aMenuPane,
       
    77         TUint aFlags)
       
    78     {
       
    79     TBool ret = EFalse;
       
    80     
       
    81     iFlags = aFlags;
       
    82     // Normal menu
       
    83     if ( aResourceId == R_PHONEBOOK_POC_MENU )
       
    84         {
       
    85         ret = ETrue;
       
    86 
       
    87 	    // If the list is empty or it has marked items, hide poc option
       
    88         if ( !(iFlags & KPbkControlEmpty) )
       
    89             {
       
    90             CAiwGenericParamList& params = iServiceHandler.InParamListL();
       
    91             TAiwPocParameterData pocParameter;
       
    92             pocParameter.iConsumerAppUid = TUid::Uid(KPbkUID3);
       
    93             pocParameter.iConsumerWindowGroup =
       
    94                 CCoeEnv::Static()->RootWin().Identifier();
       
    95             pocParameter.iCommandId = 0;// not used with menu construction!
       
    96             
       
    97             // Select POC call type
       
    98             pocParameter.iPreferredMenu = 
       
    99                 iSelector->SelectPocCallType(aFlags);
       
   100             
       
   101             // PoC parameter data always included
       
   102             TAiwGenericParam param = TAiwGenericParam(
       
   103                 EGenericParamPoCData,
       
   104                 TAiwVariant( TAiwPocParameterDataPckg(pocParameter)));
       
   105             params.AppendL(param);            
       
   106 
       
   107             // Let provider add its menu items to the menu
       
   108             iServiceHandler.InitializeMenuPaneL(
       
   109                 aMenuPane,
       
   110                 aResourceId,
       
   111                 KAiwCmdPoC,
       
   112                 params);
       
   113             }
       
   114         else
       
   115             {
       
   116             aMenuPane.SetItemDimmed(KAiwCmdPoC, ETrue);
       
   117             }
       
   118         }
       
   119 
       
   120     // Context menu
       
   121     else if (aResourceId == R_PHONEBOOK_POC_CONTEXT_MENU)
       
   122         {
       
   123         ret = ETrue;
       
   124         // Hide the item by default
       
   125         aMenuPane.SetItemDimmed(KAiwCmdPoC, ETrue);    
       
   126         
       
   127         TBool showTalkMenu = EFalse;
       
   128         // Show "Talk" in contact info context menu if field is a PoC field
       
   129         if ((aFlags & KPbkInfoView) && (aFlags & KPbkCurrentFieldPoc))
       
   130             {
       
   131             showTalkMenu = ETrue;
       
   132             }
       
   133         // Show "Talk" in contact views if there are marked items
       
   134         else if (aFlags & KPbkItemsMarked)
       
   135             {
       
   136             showTalkMenu = ETrue;
       
   137             }
       
   138         
       
   139         if (showTalkMenu)
       
   140             {
       
   141             aMenuPane.SetItemDimmed(KAiwCmdPoC, EFalse);
       
   142             
       
   143             CAiwGenericParamList& params = iServiceHandler.InParamListL();
       
   144             TAiwPocParameterData pocParameter;
       
   145             pocParameter.iConsumerAppUid = TUid::Uid(KPbkUID3);
       
   146             pocParameter.iConsumerWindowGroup =
       
   147                 CCoeEnv::Static()->RootWin().Identifier();
       
   148             pocParameter.iCommandId = 0;// not used with menu construction!
       
   149             
       
   150             // Select POC call type
       
   151             pocParameter.iPreferredMenu = 
       
   152                 iSelector->SelectPocCallType(aFlags);
       
   153             
       
   154             // PoC parameter data always included
       
   155             TAiwGenericParam param = TAiwGenericParam(
       
   156                 EGenericParamPoCData,
       
   157                 TAiwVariant( TAiwPocParameterDataPckg(pocParameter)));
       
   158             params.AppendL(param);            
       
   159 
       
   160             // Let provider add its menu items to the menu
       
   161             iServiceHandler.InitializeMenuPaneL(
       
   162                 aMenuPane,
       
   163                 aResourceId,
       
   164                 KAiwCmdPoC,
       
   165                 params);    
       
   166             }
       
   167         }
       
   168 
       
   169     return ret;
       
   170     }
       
   171 
       
   172 
       
   173 TBool CPbkAiwInterestItemPoc::HandleCommandL(
       
   174         TInt aMenuCommandId,
       
   175         const CContactIdArray& aContacts,
       
   176         const TPbkContactItemField* /*aFocusedField*/,
       
   177         TInt aServiceCommandId ,
       
   178         MPbkAiwCommandObserver* aObserver)
       
   179     {
       
   180     TBool ret = EFalse;
       
   181 
       
   182     // Only handle this command if service command is poc
       
   183     if (aServiceCommandId == KAiwCmdPoC)
       
   184         {
       
   185 		// Create the poc command object
       
   186 		MPbkCommand* cmd = CPbkAppGlobalsBase::InstanceL()->
       
   187 			CommandFactory().CreatePocCmdL
       
   188 			    (aMenuCommandId, aContacts, iFlags,
       
   189 			    iServiceHandler, *iSelector);
       
   190 
       
   191 		// Execute the command
       
   192 		TRAPD(res, cmd->ExecuteLD());
       
   193 
       
   194         // Inform observer
       
   195         if (aObserver)
       
   196             {
       
   197             aObserver->AiwCommandHandledL(aMenuCommandId,
       
   198                aServiceCommandId, res);
       
   199             }
       
   200         ret = ETrue;
       
   201         }
       
   202 
       
   203     return ret;
       
   204     }
       
   205 
       
   206 void CPbkAiwInterestItemPoc::AttachL(
       
   207         TInt aMenuResourceId,
       
   208         TInt aInterestResourceId,
       
   209         TBool aAttachBaseServiceInterest)
       
   210     {
       
   211     // Always delegate to base class!
       
   212     CPbkAiwInterestItemBase::AttachL(aMenuResourceId,
       
   213         aInterestResourceId,
       
   214         aAttachBaseServiceInterest);
       
   215     }
       
   216 
       
   217 //  End of File