uiservicetab/vimpstdetailsviewplugin/src/cvimpstdetailsviewmenuhandler.cpp
changeset 0 5e5d6b214f4f
child 10 78867dafe7eb
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implementation of detailsview plugin menu handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cvimpstdetailsviewmenuhandler.h"
       
    20 
       
    21 #include "cvimpstdetailsviewlistboxmodel.h"
       
    22 #include "cvimpstdetailsviewcontainer.h"
       
    23 #include "cvimpstdetailsviewplugin.h"
       
    24 #include "cvimpstdetailscontacthandler.h"
       
    25 #include "vimpstdetailsview.hrh"
       
    26 #include <vimpstdetailsviewpluginrsc.rsg>
       
    27 #include <ccappdetailsviewpluginrsc.rsg>
       
    28 #include <aknnotewrappers.h>
       
    29 #include <AiwContactAssignDataTypes.h>
       
    30 #include <CVPbkContactLinkArray.h>
       
    31 
       
    32 using namespace AiwContactAssign;
       
    33 // ======== MEMBER FUNCTIONS ========
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CVIMPSTDetailsViewMenuHandler::NewL
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CVIMPSTDetailsViewMenuHandler* CVIMPSTDetailsViewMenuHandler::NewL(
       
    40 									CVIMPSTDetailsViewPlugin& aPlugin, 
       
    41 									TStoreType aStoreType )
       
    42 	{
       
    43 	CVIMPSTDetailsViewMenuHandler* self = new(ELeave) CVIMPSTDetailsViewMenuHandler( aPlugin,aStoreType );
       
    44 	CleanupStack::PushL(self);
       
    45 	self->ConstructL();
       
    46 	CleanupStack::Pop(self);
       
    47 	return self;
       
    48 	}
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CVIMPSTDetailsViewMenuHandler::~CVIMPSTDetailsViewMenuHandler
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CVIMPSTDetailsViewMenuHandler::~CVIMPSTDetailsViewMenuHandler()
       
    55 	{
       
    56 	delete iAiwServiceHandler;
       
    57 	}
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CVIMPSTDetailsViewMenuHandler::CVIMPSTDetailsViewMenuHandler()
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CVIMPSTDetailsViewMenuHandler::CVIMPSTDetailsViewMenuHandler(
       
    64 	CVIMPSTDetailsViewPlugin& aPlugin,
       
    65 	TStoreType aStoreType) :
       
    66 	iPlugin(aPlugin),
       
    67 	iStoreType( aStoreType )
       
    68 	{
       
    69 	}
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CVIMPSTDetailsViewMenuHandler::ConstructL
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void CVIMPSTDetailsViewMenuHandler::ConstructL()
       
    76 	{
       
    77 	PrepareAiwMenusL();
       
    78 	}
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CVIMPSTDetailsViewMenuHandler::DynInitMenuPaneL
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void CVIMPSTDetailsViewMenuHandler::DynInitMenuPaneL(TInt aResourceId,
       
    85 												CEikMenuPane* aMenuPane )
       
    86 	{
       
    87 	if (iAiwServiceHandler && iAiwServiceHandler->HandleSubmenuL(*aMenuPane))
       
    88 	    {
       
    89 	    return;
       
    90 	    }
       
    91 	switch (aResourceId)
       
    92 		{
       
    93 		case R_VIMPSTDETAILSVIEW_MENUPANE:
       
    94 			{
       
    95 			TInt pos = 0;			
       
    96 			if ( iAiwServiceHandler->IsAiwMenu(aResourceId))
       
    97 			    {
       
    98 			    iAiwServiceHandler->InitializeMenuPaneL( *aMenuPane,
       
    99 			            aResourceId, ECCAppDetailsViewAiwBaseCmd,
       
   100 			            iAiwServiceHandler->InParamListL() );			           
       
   101 			    } 
       
   102 			if ( aMenuPane->MenuItemExists(ECCAppDetailsViewSetTopContactCmd, pos)  )
       
   103 				{
       
   104 				aMenuPane->SetItemDimmed(ECCAppDetailsViewSetTopContactCmd, ETrue );	
       
   105 				}
       
   106 			if( aMenuPane->MenuItemExists(ECCAppDetailsViewRemoveTopContactCmd, pos) )
       
   107 				{
       
   108 				aMenuPane->SetItemDimmed(ECCAppDetailsViewRemoveTopContactCmd, ETrue );
       
   109 				}
       
   110 			if (aMenuPane->MenuItemExists(ECCAppDetailsViewNumberCmd, pos) )
       
   111 				{	
       
   112 				 aMenuPane->SetItemDimmed(ECCAppDetailsViewNumberCmd,ETrue );
       
   113 				}
       
   114 			if (aMenuPane->MenuItemExists(ECCAppDetailsViewAddressCmd, pos) )
       
   115 				{
       
   116 				 aMenuPane->SetItemDimmed(ECCAppDetailsViewAddressCmd,ETrue );
       
   117 				}   
       
   118 			if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyNumberCmd, pos) )
       
   119 				{
       
   120 				 aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyNumberCmd, ETrue );
       
   121 				}
       
   122 			if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyAddressCmd, pos) )
       
   123 				{
       
   124 				aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyAddressCmd, ETrue );
       
   125 				}
       
   126 	    	if (aMenuPane->MenuItemExists(ECCAppDetailsViewImageCmd, pos) )
       
   127 				{
       
   128 				aMenuPane->SetItemDimmed(ECCAppDetailsViewImageCmd, ETrue );
       
   129 				}
       
   130 			if (aMenuPane->MenuItemExists(ECCAppDetailsViewSendBusinessCardCmd, pos) )
       
   131 				{
       
   132 				aMenuPane->SetItemDimmed(ECCAppDetailsViewSendBusinessCardCmd, ETrue );
       
   133 				}
       
   134 			if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyCmd, pos) )
       
   135 			    {
       
   136 			    aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyCmd, ETrue );
       
   137 			    }
       
   138 			// Dims the edit option in service details view.
       
   139 			if(aMenuPane->MenuItemExists(KAiwCmdAssign, pos))
       
   140 			    {                                      
       
   141 			    aMenuPane->SetItemDimmed(KAiwCmdAssign,ETrue );
       
   142 			    }
       
   143 			
       
   144             if (aMenuPane->MenuItemExists(EVIMPSTDetailsCopyCmd, pos))
       
   145                    {
       
   146                    aMenuPane->SetItemDimmed(EVIMPSTDetailsCopyCmd, ETrue );
       
   147                    }
       
   148             if (aMenuPane->MenuItemExists(EVIMPSTDetailsDeleteCmd, pos))
       
   149                 {
       
   150                 aMenuPane->SetItemDimmed(EVIMPSTDetailsDeleteCmd, ETrue );
       
   151                 }
       
   152 
       
   153 
       
   154 			const CVIMPSTDetailsViewContainer& container =
       
   155                     static_cast<const CVIMPSTDetailsViewContainer&>( iPlugin.GetContainer() );
       
   156                     
       
   157 			TInt count = container.ListBoxModel().MdcaCount();
       
   158 			if( !count )
       
   159 				{
       
   160 				// no items hide options
       
   161 				if (aMenuPane->MenuItemExists(EVIMPSTDetailsEditCmd, pos))
       
   162 					{
       
   163 					aMenuPane->SetItemDimmed(EVIMPSTDetailsEditCmd, ETrue );
       
   164 					}
       
   165 				if (aMenuPane->MenuItemExists(ECCAppDetailsViewDeleteCmd, pos) )
       
   166 					{
       
   167 					aMenuPane->SetItemDimmed(ECCAppDetailsViewDeleteCmd, ETrue );
       
   168 					}
       
   169 				if (aMenuPane->MenuItemExists(ECCAppDetailsViewCopyDetailCmd, pos) )
       
   170 					{
       
   171 					aMenuPane->SetItemDimmed(ECCAppDetailsViewCopyDetailCmd,ETrue );
       
   172 					}
       
   173 				if (aMenuPane->MenuItemExists(ECCAppDetailsViewEditItemCmd, pos) )
       
   174 					{
       
   175 					aMenuPane->SetItemDimmed(ECCAppDetailsViewEditItemCmd,ETrue );
       
   176 					}
       
   177 				}
       
   178 			break;
       
   179 			}
       
   180 	   default:
       
   181 	        break;
       
   182 	    }
       
   183 	}
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // CVIMPSTDetailsViewMenuHandler::HandleNotifyL
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 TInt CVIMPSTDetailsViewMenuHandler::HandleNotifyL(
       
   190     TInt aCmdId,
       
   191     TInt aEventId,
       
   192     CAiwGenericParamList& aEventParamList,
       
   193     const CAiwGenericParamList& /*aInParamList*/)
       
   194     {
       
   195     TInt result = KErrNone;
       
   196 
       
   197     if (aCmdId == KAiwCmdAssign)
       
   198         {
       
   199         if (aEventId == KAiwEventCompleted)
       
   200             {
       
   201             TInt index = 0;
       
   202             const TAiwGenericParam* param = aEventParamList.FindFirst(index,
       
   203                     EGenericParamContactLinkArray);
       
   204             if (param)
       
   205                 {               
       
   206                 TPtrC8 contactLinks = param->Value().AsData();
       
   207                 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC(
       
   208                         contactLinks, iPlugin.GetContactHandler()->ContactStoresL());
       
   209                 if(links)
       
   210                     {
       
   211                     iPlugin.GetContactHandler()->SetLinks(links, EFalse);
       
   212                     }                                 
       
   213                 CleanupStack::Pop(links);                     
       
   214                 }
       
   215 
       
   216             const TAiwGenericParam* indexparam = aEventParamList.FindFirst(index,
       
   217                     EGenericParamContactItem);
       
   218             if (indexparam)
       
   219                 {
       
   220                 const CVIMPSTDetailsViewContainer& container =
       
   221                 static_cast<const CVIMPSTDetailsViewContainer&>(iPlugin.GetContainer());
       
   222                 TInt index = indexparam->Value().AsTInt32();
       
   223                 container.ListBoxModel().SetFocusedListIndex(index);
       
   224                 }
       
   225             result = ETrue;
       
   226             }
       
   227         else if (aEventId == KAiwEventCanceled)
       
   228             {
       
   229             //if cancelled
       
   230             result = ETrue;    
       
   231             }
       
   232         else if (aEventId == KAiwEventQueryExit)
       
   233             {
       
   234             //issue command to cancel the previous request.
       
   235             iAiwServiceHandler->ExecuteServiceCmdL(
       
   236                     KAiwCmdAssign,
       
   237                     iAiwServiceHandler->InParamListL(),
       
   238                     iAiwServiceHandler->OutParamListL(),
       
   239                     KAiwOptCancel,
       
   240                     this);
       
   241             result = ETrue;
       
   242             }
       
   243         }
       
   244 
       
   245     return result;
       
   246     }
       
   247 // ---------------------------------------------------------------------------
       
   248 // CVIMPSTDetailsViewMenuHandler::HandleCommandL
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 void CVIMPSTDetailsViewMenuHandler::HandleCommandL(TInt aCommand)
       
   252 	{
       
   253 	// TODO : dependency on cca , they are not deleting the menu items Then check if command is normal application command
       
   254 	switch (aCommand)
       
   255 		{
       
   256 	    case KAiwCmdAssign:// AIW service cmd for Editing
       
   257 	        {
       
   258 	        if(iAiwServiceHandler && (iStoreType == EStoreLocal))
       
   259 	            {
       
   260 	            DoEditCmdL();
       
   261 	            }	        
       
   262 	        break;
       
   263 	        }
       
   264 		case EVIMPSTDetailsEditCmd:
       
   265 		case ECCAppDetailsViewEditItemCmd:
       
   266 			{
       
   267 			//TODO: in case of server store nick names has to be supported
       
   268 			break;	
       
   269 			}
       
   270 		case EVIMPSTDetailsDeleteCmd:
       
   271 		case ECCAppDetailsViewDeleteCmd:
       
   272 			{
       
   273 			DoDeleteCmdL();
       
   274 			break;
       
   275 			}
       
   276 	   	case EVIMPSTDetailsCopyCmd:
       
   277 		case ECCAppDetailsViewCopyDetailCmd:
       
   278 			{
       
   279 			DoCopyCmdL();
       
   280 			break;
       
   281 			}
       
   282 		default:
       
   283 			break;
       
   284 		}
       
   285 	}
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // CVIMPSTDetailsViewMenuHandler::DoEditCmdL
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 void CVIMPSTDetailsViewMenuHandler::DoEditCmdL()
       
   292 	{
       
   293 	const CVIMPSTDetailsViewContainer& container =
       
   294 	static_cast<const CVIMPSTDetailsViewContainer&>(iPlugin.GetContainer());
       
   295 
       
   296 
       
   297 	CAiwGenericParamList& inParamList = iAiwServiceHandler->InParamListL();
       
   298 
       
   299 	inParamList.AppendL(TAiwGenericParam(
       
   300 	        EGenericParamContactAssignData,
       
   301 	        TAiwVariant(TAiwSingleContactAssignDataV1Pckg(
       
   302 	                TAiwSingleContactAssignDataV1().SetFlags(EskipInfoNotes)))));
       
   303 
       
   304 	HBufC8* packedLinks = iPlugin.GetContactHandler()->Links()->PackLC();
       
   305 
       
   306 	inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
       
   307 	        TAiwVariant( *packedLinks)));
       
   308 
       
   309 	TInt focusIndex = container.ListBoxModel().FocusedFieldIndex();
       
   310 
       
   311 	// TODO: use int instead of buf.
       
   312 	TBuf<8> focusIndexBuf;
       
   313 	focusIndexBuf.Num(focusIndex);
       
   314 	const TAiwVariant focusIndexVariant(focusIndexBuf);
       
   315 
       
   316 	inParamList.AppendL(TAiwGenericParam(EGenericParamContactItem, focusIndexVariant));
       
   317 
       
   318 	iAiwServiceHandler->ExecuteServiceCmdL(
       
   319 	        KAiwCmdAssign,
       
   320 	        inParamList,
       
   321 	        iAiwServiceHandler->OutParamListL(),
       
   322 	        NULL,
       
   323 	        this);
       
   324 
       
   325 	CleanupStack::PopAndDestroy(packedLinks);
       
   326 	    
       
   327 	}
       
   328 
       
   329 // ---------------------------------------------------------------------------
       
   330 // CVIMPSTDetailsViewMenuHandler::DoDeleteCmdL
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 void CVIMPSTDetailsViewMenuHandler::DoDeleteCmdL()
       
   334 	{
       
   335 	CAknInformationNote* informationNote = new(ELeave) CAknInformationNote;
       
   336 	informationNote->ExecuteLD(_L("Delete not supported yet"));
       
   337 	}
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // CVIMPSTDetailsViewMenuHandler::DoCopyCmdL
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 void CVIMPSTDetailsViewMenuHandler::DoCopyCmdL()
       
   344 	{
       
   345 	CAknInformationNote* informationNote = new(ELeave) CAknInformationNote;
       
   346 	informationNote->ExecuteLD(_L("Copy not supported yet"));
       
   347 	}
       
   348 // ---------------------------------------------------------------------------
       
   349 // CVIMPSTDetailsViewMenuHandler::PrepareAiwMenusL
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CVIMPSTDetailsViewMenuHandler::PrepareAiwMenusL()
       
   353     {
       
   354     // Initialisation of AIW Servicehandler cannot be in
       
   355     // ConstructL, since the menus of plugin are given
       
   356     // later via ProvideApplicationResourcesL(..)
       
   357     iAiwServiceHandler = CAiwServiceHandler::NewL();
       
   358     iAiwServiceHandler->AttachL(
       
   359             R_VIMPSTDETAILSVIEW_AIW_SERVICE_INTERESTS);
       
   360     
       
   361     }
       
   362 // End of File