uiservicetab/vimpstui/src/cvimpstuiblockview.cpp
changeset 0 5e5d6b214f4f
child 11 bef90b82da71
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 for CVIMPSTUiBlockView.
       
    15  *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "cvimpstuiblockview.h"
       
    21 #include "cvimpstuiblockviewcontrol.h"
       
    22 #include "cvimpstenginepresencesubservice.h"
       
    23 #include "vimpstutilswaitnote.h"
       
    24 #include "mvimpstengine.h"
       
    25 #include "vimpstextentionuiuid.h"
       
    26 #include "cvimpstuiextensionservice.h"
       
    27 #include "vimpstui.hrh"
       
    28 #include "cvimpstuistatuspanehandler.h"
       
    29 #include "cvimpstcmdhandler.h"
       
    30 // System includes
       
    31 #include <StringLoader.h>
       
    32 // Pbk2
       
    33 #include <MPbk2AppUi.h>
       
    34 #include <CPbk2UIExtensionView.h>
       
    35 #include <MPbk2ViewActivationTransaction.h>
       
    36 #include <MPbk2ViewExplorer.h>
       
    37 #include <MPbk2StartupMonitor.h>
       
    38 #include <eikmenup.h>
       
    39 #include <aiwcommon.hrh>
       
    40 //resource
       
    41 #include <vimpstuires.rsg>
       
    42 #include <ExtensionManagerRes.rsg>
       
    43 
       
    44 using namespace Phonebook2;
       
    45 
       
    46 // ================= MEMBER FUNCTIONS =======================
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CVIMPSTUiBlockView::CVIMPSTUiBlockView
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 CVIMPSTUiBlockView::CVIMPSTUiBlockView( 
       
    53 				MxSPViewMapper& aMapper, 
       
    54 			    MxSPContactManager& aContactManager, 
       
    55 			    TUint aBlockViewId,
       
    56 			    CPbk2UIExtensionView& aView,
       
    57 			    CVIMPSTUIExtensionService& aServiceData,
       
    58 			    MVIMPSTEngine& aEngine ,
       
    59 			    MVIMPSTCmdHandler& aCommandHandler) :
       
    60 			    CxSPBaseView( aMapper, aContactManager, aView ),
       
    61 			 	iBlockViewId( aBlockViewId ),
       
    62 			    iEngine(aEngine),
       
    63 			    iExtensionService( aServiceData ),
       
    64 			    iCommandHandler( aCommandHandler )
       
    65     {
       
    66 	
       
    67     }
       
    68     
       
    69 // --------------------------------------------------------------------------
       
    70 // CVIMPSTUiBlockView::ConstructL
       
    71 // --------------------------------------------------------------------------
       
    72 //
       
    73 void CVIMPSTUiBlockView::ConstructL()
       
    74     {
       
    75     ViewBaseConstructL( KIMCONTACTSEXTNIMPLEMENTATIONUID, iBlockViewId );
       
    76 
       
    77     iPresenceSubService = iEngine.GetPreseceSubService();
       
    78     if(iPresenceSubService)
       
    79         {
       
    80         iBlockedList = iPresenceSubService->GetBlockedList();
       
    81         }
       
    82     
       
    83     }
       
    84 
       
    85 
       
    86 // --------------------------------------------------------------------------
       
    87 // CVIMPSTUiBlockView::NewL
       
    88 // --------------------------------------------------------------------------
       
    89 //
       
    90 CVIMPSTUiBlockView* CVIMPSTUiBlockView::NewL( MxSPViewMapper& aMapper, 
       
    91 			    MxSPContactManager& aContactManager, 
       
    92 			    TUint aBlockViewId,
       
    93 			    CPbk2UIExtensionView& aView,
       
    94 			    CVIMPSTUIExtensionService& aServiceData,
       
    95 			    MVIMPSTEngine& aEngine ,
       
    96 			    MVIMPSTCmdHandler& aCommandHandler)
       
    97     {
       
    98     CVIMPSTUiBlockView* self = new(ELeave) CVIMPSTUiBlockView( aMapper, 
       
    99             aContactManager,
       
   100             aBlockViewId,
       
   101             aView, 
       
   102             aServiceData,
       
   103             aEngine,
       
   104             aCommandHandler );
       
   105     CleanupStack::PushL(self);
       
   106     self->ConstructL();
       
   107     CleanupStack::Pop(self);
       
   108     return self;
       
   109     }
       
   110 
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CVIMPSTUiBlockView::~CVIMPSTUiBlockView()
       
   115 // C++ Destructor 
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 CVIMPSTUiBlockView::~CVIMPSTUiBlockView()
       
   119     {
       
   120     delete iNaviDecorator;
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // CVIMPSTUiBlockView::HandleCommandL( TInt aCommand )
       
   125 // This class handles all commands from menu
       
   126 // ---------------------------------------------------------
       
   127 //
       
   128 void CVIMPSTUiBlockView::HandleCommandL( TInt aCommand )
       
   129     {
       
   130 	
       
   131    	switch ( aCommand ) 
       
   132 		{
       
   133 		//Next two commands have same function
       
   134 		case EAknSoftkeyBack:
       
   135 			{
       
   136 
       
   137 			// this might get called when the view is not active
       
   138 			// back key pressed, activate tabbed view.
       
   139 			// CPbk2ViewState is not utilized here, but here the
       
   140 			// focused contact info could be delivered to next view, if required later
       
   141 			CPbk2ViewState* state = NULL; 
       
   142 
       
   143 			TInt tabViewId;
       
   144 			TInt err = iMapper.GetNewView( KIMCONTACTSEXTNIMPLEMENTATIONUID, 
       
   145 									   iExtensionService.TabbedViewId(), 
       
   146 									   tabViewId );
       
   147 			User::LeaveIfError( err );            	
       
   148 			Pbk2AppUi()->Pbk2ViewExplorer()->ActivatePhonebook2ViewL( 
       
   149 										TUid::Uid(tabViewId), 
       
   150 										state );
       
   151 
       
   152 			break;
       
   153 			}
       
   154 		case  ECmdUnBlock:
       
   155 			{
       
   156 			//show wait note
       
   157 			// load, format and show confirmation note
       
   158 			HBufC* unblockContact = iContainer->GetFocusedContactLC();
       
   159 		    if(unblockContact)
       
   160 				{
       
   161 				HBufC* prompt = StringLoader::LoadLC( R_QTN_CHAT_UNBLOCKING, *unblockContact );
       
   162 				CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( *prompt );
       
   163 	        	iCommandHandler.HandleCommandL(ECmdUnBlockContact, this, unblockContact  );
       
   164 				CleanupStack::PopAndDestroy( 3,unblockContact );//note;prompt;unblockContact.
       
   165 				}
       
   166 			break;
       
   167 			}
       
   168 			default:
       
   169 		    {
       
   170             Pbk2AppUi()->HandleCommandL( aCommand );
       
   171             break;
       
   172             }
       
   173 		
       
   174 	    }
       
   175     }
       
   176 
       
   177 
       
   178 // ---------------------------------------------------------
       
   179 // CVIMPSTUiSearchView::DynInitMenuPaneL()
       
   180 // Initialises menu pane when needed
       
   181 // (other items were commented in a header).
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 void CVIMPSTUiBlockView::DynInitMenuPaneL( TInt aResourceId,
       
   185                                      CEikMenuPane* aMenuPane )
       
   186     {
       
   187     //using the existing menu resource as it contains unblock item
       
   188     if( aResourceId == R_EXTENSION_MANAGER_MENU)
       
   189         {
       
   190         //add search view menu items 
       
   191         aMenuPane->AddMenuItemsL( R_SERVTAB_TABBED_VIEW_MENU ); 
       
   192         aMenuPane->SetItemDimmed(ECmdContactAddAsFriend,ETrue);
       
   193         aMenuPane->SetItemDimmed(KAiwCmdCall,ETrue);
       
   194         aMenuPane->SetItemDimmed(ECmdCloseConversation,ETrue);
       
   195         aMenuPane->SetItemDimmed(ECmdCreateNewOption,ETrue);
       
   196         aMenuPane->SetItemDimmed(ECmdContactDetails,ETrue);
       
   197         aMenuPane->SetItemDimmed(ECmdOpenFriendRequest,ETrue);
       
   198         aMenuPane->SetItemDimmed(ECmdContactEdit,ETrue);
       
   199         aMenuPane->SetItemDimmed(ECmdAIWAddToContact,ETrue);
       
   200         aMenuPane->SetItemDimmed(ECmdAIWLinkToContact,ETrue);
       
   201         aMenuPane->SetItemDimmed(ECmdBlock,ETrue);
       
   202         aMenuPane->SetItemDimmed(ECmdContactDelete,ETrue);
       
   203         aMenuPane->SetItemDimmed(ECmdMyAvatar,ETrue);
       
   204         aMenuPane->SetItemDimmed(ECmdChangeStatus,ETrue);
       
   205         if(0==iBlockedList->Count())
       
   206             {
       
   207             aMenuPane->SetItemDimmed(ECmdUnBlock,ETrue);
       
   208             }
       
   209         }
       
   210     }
       
   211 
       
   212 // ---------------------------------------------------------
       
   213 // CVIMPSTUiBlockView::DoActivateViewL()
       
   214 // Activates view
       
   215 // (other items were commented in a header).
       
   216 // ---------------------------------------------------------
       
   217 //
       
   218 void CVIMPSTUiBlockView::DoActivateViewL( const TVwsViewId& aPrevViewId,
       
   219         									TUid /*aCustomMessageId*/, 
       
   220         									const TDesC8&  /*aCustomMessage*/ )
       
   221     {
       
   222  
       
   223     HBufC* titleText = StringLoader::LoadLC( R_QTN_SERVTAB_TITLE_BLOCKEDLIST );
       
   224     
       
   225     //to set the icon ( context pane image) as in tabbed view
       
   226     MPbk2ViewActivationTransaction* viewActivationTransaction =
       
   227         Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC(
       
   228             iView.Id(),
       
   229             aPrevViewId,
       
   230             titleText,
       
   231             NULL,
       
   232             EUpdateAll );            
       
   233    
       
   234 	// Notifies startup monitor of view activation
       
   235   if( Pbk2AppUi()->Pbk2StartupMonitor() )
       
   236       {
       
   237       Pbk2AppUi()->Pbk2StartupMonitor()->
       
   238           NotifyViewActivationL( iView.Id() );
       
   239       }
       
   240 	 	
       
   241     if (!iContainer)
       
   242         {
       
   243         iContainer = CVIMPSTUiBlockViewControl::NewL(*this,iView, iEngine, iBlockedList );
       
   244         CCoeEnv::Static()->AppUi()->AddToStackL( iView, iContainer );
       
   245         iContainer->SetMopParent( &iView );        
       
   246         iContainer->SetRect( iView.ClientRect() );
       
   247         iContainer->ActivateL();
       
   248         iContainer->UpdateCbaL();
       
   249         } 
       
   250         
       
   251     // Commit application-wide state changes
       
   252     viewActivationTransaction->Commit();
       
   253     CleanupStack::PopAndDestroy(); //viewActivationTransaction  
       
   254  	CleanupStack::PopAndDestroy( titleText );            
       
   255     // Change the navigation pane from tabs to text label    
       
   256     UpdateNaviPaneTextL();  
       
   257     //resetting the blocked list to empty.and show it in blocked view.
       
   258     iBlockedList->ResetAndDestroy();
       
   259     iContainer->UpdateBlockedListL();
       
   260     //set the text as updating blocked list while fetching blocked list
       
   261     iContainer->SetUpdatingTextsToListboxL();
       
   262     //fetch the fresh blocked list from server..
       
   263     FetchBlockedListFromServerL();
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------
       
   267 // CVIMPSTUiBlockView::DoDeactivate()
       
   268 // Deactivates the view
       
   269 // (other items were commented in a header).
       
   270 // ---------------------------------------------------------
       
   271 //
       
   272 void CVIMPSTUiBlockView::DoDeactivate()
       
   273 	{
       
   274     if (iContainer)
       
   275 	    {
       
   276         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
   277         delete iContainer;
       
   278         iContainer = NULL;
       
   279         }
       
   280    	}
       
   281 
       
   282 
       
   283 // ---------------------------------------------------------
       
   284 // CVIMPSTUiBlockView::UpdateNaviPaneTextL()
       
   285 // ---------------------------------------------------------
       
   286 //
       
   287 void CVIMPSTUiBlockView::UpdateNaviPaneTextL( )
       
   288 	{
       
   289 	// Change the navigation pane from tabs to text label    
       
   290     CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
   291     CAknNavigationControlContainer* np =
       
   292     						static_cast<CAknNavigationControlContainer*>(
       
   293     									sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   294     delete iNaviDecorator;
       
   295     iNaviDecorator = NULL;
       
   296     //fix for disableing navigation search string text, makeing it null
       
   297    	iNaviDecorator = np->CreateNavigationLabelL( iEngine.ServiceName());
       
   298 	  
       
   299     np->PushL( *iNaviDecorator );
       
   300     sp->DrawNow();  
       
   301   	}
       
   302 
       
   303 // --------------------------------------------------------------------------
       
   304 // CVIMPSTUiSearchView::HandleStatusPaneSizeChange
       
   305 // --------------------------------------------------------------------------
       
   306 //
       
   307 void CVIMPSTUiBlockView::HandleStatusPaneSizeChange()
       
   308     {
       
   309     // Resize the container to fill the client rectangle
       
   310     if (iContainer)
       
   311         {
       
   312         iContainer->SetRect( iView.ClientRect() );
       
   313         }
       
   314     }
       
   315 
       
   316 // --------------------------------------------------------------------------
       
   317 // CVIMPSTUiSearchView::FetchBlockedListFromServerL
       
   318 // --------------------------------------------------------------------------
       
   319 //
       
   320 void CVIMPSTUiBlockView::FetchBlockedListFromServerL()
       
   321 	{
       
   322 	iEngine.RegisterBlockedListObserver(this);
       
   323 	iCommandHandler.HandleCommandL(EFetchBlockedList, this, NULL );
       
   324 	}
       
   325 
       
   326 // --------------------------------------------------------------------------
       
   327 // CVIMPSTUiSearchView::HandleBlockedListFetchCompleteL
       
   328 // --------------------------------------------------------------------------
       
   329 //
       
   330 void CVIMPSTUiBlockView::HandleBlockedListFetchCompleteL()
       
   331 	{
       
   332 	if(iContainer)
       
   333 		{
       
   334 		iContainer->UpdateBlockedListL();	
       
   335 		}
       
   336 	}
       
   337 
       
   338 // --------------------------------------------------------------------------
       
   339 // CVIMPSTUiSearchView::CommandFinishedL
       
   340 // --------------------------------------------------------------------------
       
   341 //
       
   342 void CVIMPSTUiBlockView::CommandFinishedL( const MVIMPSTCmd& /*aCommand */)
       
   343 	{
       
   344 		
       
   345 	}
       
   346 
       
   347 // --------------------------------------------------------------------------
       
   348 // CVIMPSTUiSearchView::HandleCommandEventL
       
   349 // --------------------------------------------------------------------------
       
   350 //
       
   351 void CVIMPSTUiBlockView::HandleCommandEventL( TVIMPSTEnums::TVIMPSTRegistrationState /*aState*/, 
       
   352 								TInt /*aServiceError*/) 
       
   353 	{
       
   354 	
       
   355 	}
       
   356 
       
   357 //  End of File