meetingrequest/mrgui/src/cesmrtrackingviewdialog.cpp
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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 : ESMR tracking view dialog
       
    15 *  Version     : %version: tr1sido#9 %
       
    16 *
       
    17 */
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "cesmrtrackingviewdialog.h"
       
    21 
       
    22 // SYSTEM INCLUDE
       
    23 #include <AknUtils.h>
       
    24 #include <StringLoader.h>
       
    25 #include <calentry.h>
       
    26 #include <AiwServiceHandler.h>
       
    27 #include <featmgr.h>
       
    28 #include <bldvariant.hrh>
       
    29 //<cmail>
       
    30 #include <featmgr.h>
       
    31 //</cmail>
       
    32 
       
    33 #include "cesmrpolicy.h"
       
    34 //</cmail>
       
    35 #include <esmrgui.rsg>
       
    36 
       
    37 #include "esmrgui.hrh"
       
    38 #include "cesmrview.h"
       
    39 #include "cesmrviewerfieldstorage.h"
       
    40 #include "mesmrcalentry.h"
       
    41 #include "cesmrcontactmenuhandler.h"
       
    42 #include "esmrconfig.hrh"
       
    43 #include "esmrinternaluid.h"
       
    44 
       
    45 #ifdef _DEBUG
       
    46 namespace // codescanner::namespace
       
    47 {
       
    48 // Literal for viewer dialog
       
    49 _LIT( KESMRTrackinglgPanicTxt, "ESMRTrackingDlg" );
       
    50 
       
    51 enum TESMRViewerDlgPanic
       
    52     {
       
    53     EESMRTrackingVieweDlgInvalidCommand
       
    54     };
       
    55 
       
    56 void Panic( TESMRViewerDlgPanic aPanic )
       
    57     {
       
    58     User::Panic( KESMRTrackinglgPanicTxt, aPanic );
       
    59     }
       
    60 }
       
    61 #endif
       
    62 
       
    63 // ======== MEMBER FUNCTIONS ========
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CESMRTrackingViewDialog::NewL
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CESMRTrackingViewDialog* CESMRTrackingViewDialog::NewL(
       
    70 		CESMRPolicy* aPolicy,
       
    71 		MESMRCalEntry& aEntry,
       
    72 		MAgnEntryUiCallback& aCallback )
       
    73     {
       
    74     FUNC_LOG;
       
    75     CESMRTrackingViewDialog* self =
       
    76 	new (ELeave) CESMRTrackingViewDialog(aEntry,aCallback);
       
    77 	CleanupStack::PushL( self );
       
    78 	self->ConstructL( aPolicy );
       
    79 	CleanupStack::Pop( self );
       
    80 	return self;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CESMRTrackingViewDialog::~CESMRTrackingViewDialog
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CESMRTrackingViewDialog::~CESMRTrackingViewDialog()
       
    88     {
       
    89     FUNC_LOG;
       
    90     if ( iFeatureManagerInitialized )
       
    91         {
       
    92         FeatureManager::UnInitializeLib();
       
    93         }
       
    94 
       
    95     if ( iServiceHandler )
       
    96         {
       
    97         iServiceHandler->DetachMenu(R_MR_TRACKING_VIEW_MENU, R_PS_AIW_INTEREST);
       
    98         delete iServiceHandler;
       
    99         }
       
   100 
       
   101     iESMRStatic.Close();
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CESMRTrackingViewDialog::CESMRTrackingViewDialog
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 CESMRTrackingViewDialog::CESMRTrackingViewDialog( 
       
   109 		MESMRCalEntry& aEntry,
       
   110 		MAgnEntryUiCallback& aCallback) :
       
   111     iEntry( aEntry ),
       
   112     iCallback(aCallback)
       
   113     {
       
   114     FUNC_LOG;
       
   115     // Do nothing
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CESMRTrackingViewDialog::ConstructL
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CESMRTrackingViewDialog::ConstructL(CESMRPolicy* aPolicy)
       
   123     {
       
   124     FUNC_LOG;
       
   125     CAknDialog::ConstructL ( R_TRACKING_DIALOG_MENUBAR );
       
   126     iPolicy = aPolicy;
       
   127     iESMRStatic.ConnectL();
       
   128     iESMRStatic.ContactMenuHandlerL().Reset();
       
   129 
       
   130     TRect clientRect;
       
   131     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, clientRect );
       
   132 
       
   133     TBool responseReady(EFalse);
       
   134 
       
   135     FeatureManager::InitializeLibL();
       
   136     iFeatureManagerInitialized = ETrue;
       
   137 
       
   138 	// <cmail> remove custom feature KFeatureIdPrintingFrameworkCalendarPlugin 
       
   139 	// </cmail>		
       
   140 
       
   141     // Sort the attendees list so that Req attendeees comes  first
       
   142     // and then opt attendees
       
   143     SortAttendeesL();
       
   144 
       
   145     // Set the index of builder to zero so that
       
   146     // participant field is created from index.
       
   147 
       
   148     iESMRStatic.SetCurrentFieldIndex(0);
       
   149 
       
   150     CESMRViewerFieldStorage* storage =
       
   151              CESMRViewerFieldStorage::NewL(
       
   152                      aPolicy,
       
   153                      NULL,
       
   154                      responseReady,
       
   155                      *this,
       
   156                      CountAttendeesL(CCalAttendee::EReqParticipant),
       
   157                      CountAttendeesL(CCalAttendee::EOptParticipant) );
       
   158 
       
   159     CleanupStack::PushL( storage );
       
   160     // storage ownership is transferred to CESMRView
       
   161     iView = CESMRView::NewL(storage, iEntry, clientRect );
       
   162     CleanupStack::Pop( storage ); 
       
   163      
       
   164     if ( iEntry.Entry().SummaryL().Length() == 0 )
       
   165 		 {
       
   166 		 // if no title, set unnamed text:
       
   167 		 HBufC* title = StringLoader::LoadLC (R_QTN_MEET_REQ_CONFLICT_UNNAMED);
       
   168 		 iView->SetTitleL( *title, ETrue );
       
   169 		 CleanupStack::PopAndDestroy( title );
       
   170 		 }
       
   171     else
       
   172          {
       
   173          iView->SetTitleL( iEntry.Entry().SummaryL(), ETrue );
       
   174          }
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // CESMRTrackingViewDialog::CreateCustomControlL
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 SEikControlInfo
       
   182     CESMRTrackingViewDialog::CreateCustomControlL( TInt aType )
       
   183     {
       
   184     FUNC_LOG;
       
   185     SEikControlInfo controlInfo;
       
   186     controlInfo.iControl = NULL;
       
   187     controlInfo.iFlags = 0;
       
   188     controlInfo.iTrailerTextId = 0;
       
   189 
       
   190     if ( aType == EEsMrTrackingType )
       
   191         {
       
   192         controlInfo.iControl = iView;
       
   193         }
       
   194 
       
   195     return controlInfo;
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // CESMRTrackingViewDialog::OfferKeyEventL
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 TKeyResponse CESMRTrackingViewDialog::OfferKeyEventL
       
   203         (const TKeyEvent& aEvent, TEventCode aType)
       
   204     {
       
   205     FUNC_LOG;
       
   206     TKeyResponse response = CAknDialog::OfferKeyEventL( aEvent, aType );
       
   207 	
       
   208     if ( ( response == EKeyWasNotConsumed && aEvent.iCode != EKeyEscape)
       
   209 		   && (!MenuShowing()) )
       
   210 		{
       
   211 		response = iView->OfferKeyEventL( aEvent, aType );
       
   212 		}
       
   213 	return response;
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // CESMRTrackingViewDialog::OkToExitL
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 TBool CESMRTrackingViewDialog::OkToExitL (TInt aButtonId)
       
   221     {
       
   222     FUNC_LOG;
       
   223     TBool res( EFalse );
       
   224     // show options
       
   225     switch ( aButtonId )
       
   226         {
       
   227         case EAknSoftkeyOptions:
       
   228             {
       
   229             CAknDialog::DisplayMenuL();
       
   230             break;
       
   231             }            
       
   232         case EESMRCmdBack:
       
   233             {
       
   234             res = ETrue;
       
   235             break;
       
   236             }            
       
   237         case EESMRCmdCall:
       
   238             {
       
   239             iESMRStatic.ContactMenuHandlerL().ExecuteOptionsMenuL( 
       
   240 												EESMRCmdActionMenuFirst );
       
   241             break;
       
   242             }
       
   243         default:
       
   244             {
       
   245             res = CAknDialog::OkToExitL( aButtonId );
       
   246             break;
       
   247             }       
       
   248         }
       
   249 
       
   250     return res;
       
   251     }
       
   252 
       
   253 // ---------------------------------------------------------------------------
       
   254 // CESMRTrackingViewDialog::CountAttendeesL
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 TInt CESMRTrackingViewDialog::CountAttendeesL( // codescanner::intleaves
       
   258         CCalAttendee::TCalRole aRole)
       
   259     {
       
   260     FUNC_LOG;
       
   261     RPointerArray<CCalAttendee>& calAttendeeList = iEntry.Entry().AttendeesL();
       
   262     
       
   263     TInt totalParticipants = calAttendeeList.Count();
       
   264     TInt totalAttendees(0);
       
   265 
       
   266     for (TInt i=0; i< totalParticipants; i++)
       
   267         {
       
   268         CCalAttendee::TCalRole role = CCalAttendee::ENonParticipant;
       
   269         role = calAttendeeList[i]->RoleL();
       
   270         if ( role == aRole )
       
   271         	{
       
   272         	++totalAttendees;
       
   273         	}
       
   274         }
       
   275     return totalAttendees;
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // CESMRTrackingViewDialog::SortAttendeesL
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 void CESMRTrackingViewDialog::SortAttendeesL()
       
   283     {
       
   284     FUNC_LOG;
       
   285     RPointerArray<CCalAttendee>& attendees = iEntry.Entry().AttendeesL();
       
   286     // Sort the attendees so that REqPart come first and then optPart
       
   287     // This is required once only
       
   288      TInt i, j;
       
   289      TBool flag = ETrue;    // set flag to true to begin initial pass
       
   290      TInt arrayLength = attendees.Count();
       
   291      for(i = 1; (i <= arrayLength) && flag; i++)
       
   292          {
       
   293           flag = EFalse;
       
   294           for (j=0; j < (arrayLength -1); j++)
       
   295               {
       
   296               CCalAttendee::TCalRole lhs = CCalAttendee::ENonParticipant;
       
   297               CCalAttendee::TCalRole rhs = CCalAttendee::ENonParticipant;
       
   298               lhs = attendees[j+1]->RoleL();
       
   299               rhs = attendees[j]->RoleL();
       
   300               if ( lhs < rhs )
       
   301                   {
       
   302                   CCalAttendee* tempAttendee = attendees[j];
       
   303                   attendees[j]   = attendees[j+1];
       
   304                   attendees[j+1] = tempAttendee;
       
   305                   flag = ETrue;   // indicates that a swap occurred.
       
   306                   }
       
   307               }// Inner loop (j)
       
   308          } // Outer loop (i)
       
   309     }
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // CESMRTrackingViewDialog::ProcessCommandL
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 void CESMRTrackingViewDialog::ProcessCommandL( TInt aCommand )
       
   316     {
       
   317     FUNC_LOG;
       
   318     TRAPD( err, DoProcessCommandL( aCommand ) );
       
   319     if ( err != KErrNone &&
       
   320          err != KErrCancel &&
       
   321          err != KErrArgument )
       
   322         {
       
   323         User::Leave(err);
       
   324         }
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------------------------
       
   328 // CESMRTrackingViewDialog::DoProcessCommandL
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 void CESMRTrackingViewDialog::DoProcessCommandL( TInt aCommand )
       
   332     {
       
   333     FUNC_LOG;
       
   334     CAknDialog::ProcessCommandL( aCommand );
       
   335     switch ( aCommand )
       
   336         {
       
   337         case EESMRCmdPrint: // Fall through
       
   338         case EESMRCmdPrint_Reserved1: // Fall through
       
   339         case EESMRCmdPrint_Reserved2: // Fall through
       
   340         case EESMRCmdPrint_Reserved3: // Fall through
       
   341         case EESMRCmdPrint_Reserved4:
       
   342             {
       
   343             this->MakeVisible(EFalse); 
       
   344             HandlePrintCommandL(aCommand);
       
   345             this->MakeVisible(ETrue); 
       
   346             break;
       
   347             }
       
   348         case EAknCmdExit:
       
   349         	{
       
   350             TryExitL( aCommand );
       
   351             break;
       
   352         	}
       
   353         case EAknCmdHelp:
       
   354             {
       
   355             iView->LaunchViewerHelpL();
       
   356             break;
       
   357             }
       
   358         default:
       
   359         	{
       
   360             if ( aCommand >= EESMRCmdActionMenuFirst && 
       
   361             	 aCommand <= EESMRCmdActionMenuLast )
       
   362                 {
       
   363                 iESMRStatic.ContactMenuHandlerL().ExecuteOptionsMenuL( 
       
   364 																aCommand );
       
   365                 }
       
   366             else
       
   367                 {
       
   368                 __ASSERT_DEBUG( EFalse, 
       
   369                 		Panic( EESMRTrackingVieweDlgInvalidCommand ) );
       
   370                 }
       
   371             break;
       
   372         	}
       
   373         }
       
   374     }
       
   375 
       
   376 // ---------------------------------------------------------------------------
       
   377 // CESMRTrackingViewDialog::DynInitMenuPaneL
       
   378 // ---------------------------------------------------------------------------
       
   379 //
       
   380 void CESMRTrackingViewDialog::DynInitMenuPaneL(
       
   381 		TInt aResourceId,
       
   382         CEikMenuPane* aMenuPane )
       
   383     {
       
   384     FUNC_LOG;
       
   385     if ( iServiceHandler )
       
   386         {
       
   387         if ( iServiceHandler->HandleSubmenuL ( *aMenuPane ) )
       
   388             {
       
   389             return;
       
   390             }
       
   391         }
       
   392     if ( aResourceId == R_ACTION_MENU )
       
   393         {
       
   394         iESMRStatic.ContactMenuHandlerL().InitOptionsMenuL( aMenuPane );
       
   395         }
       
   396 
       
   397     if ( aResourceId == R_MR_TRACKING_VIEW_MENU )
       
   398         {
       
   399 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
       
   400 		   {
       
   401 		   // remove help support in pf5250
       
   402 		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
   403 		   }
       
   404 		
       
   405 	    // <cmail> remove custom feature KFeatureIdPrintingFrameworkCalendarPlugin 
       
   406 	    // </cmail>				
       
   407         aMenuPane->SetItemDimmed( EESMRCmdPrint, ETrue );
       
   408 
       
   409         aMenuPane->SetItemDimmed( EESMRCmdActionMenu, 
       
   410         		!iESMRStatic.ContactMenuHandlerL().OptionsMenuAvailable() );
       
   411         }
       
   412     }
       
   413 
       
   414 // ---------------------------------------------------------------------------
       
   415 // CESMRTrackingViewDialog::ActivateL
       
   416 // ---------------------------------------------------------------------------
       
   417 //
       
   418 void CESMRTrackingViewDialog::ActivateL()
       
   419     {
       
   420     FUNC_LOG;
       
   421     CAknDialog::ActivateL();
       
   422     iView->InternalizeL();
       
   423     }
       
   424 
       
   425 // ---------------------------------------------------------------------------
       
   426 // CESMRTrackingViewDialog::ExecuteViewLD
       
   427 // ---------------------------------------------------------------------------
       
   428 //
       
   429 TInt CESMRTrackingViewDialog::ExecuteViewLD()
       
   430     {
       
   431     FUNC_LOG;
       
   432     return ExecuteLD( R_MRTRACKING_DIALOG );
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // CESMRTrackingViewDialog::HandlePrintCommandL
       
   437 // ---------------------------------------------------------------------------
       
   438 //
       
   439 void CESMRTrackingViewDialog::HandlePrintCommandL(TInt aCommand)
       
   440     {
       
   441     FUNC_LOG;
       
   442     CAiwGenericParamList& inParams = iServiceHandler->InParamListL();
       
   443 
       
   444     // Param date
       
   445 
       
   446     TCalTime startTime = iEntry.Entry().StartTimeL();
       
   447 
       
   448     TAiwGenericParam dateParam( EGenericParamDateTime );
       
   449     TTime activeDay = startTime.TimeUtcL();
       
   450 
       
   451     TAiwGenericParam calendarParam( EGenericParamCalendarItem );
       
   452     calendarParam.Value().Set( TUid::Uid(iEntry.Entry().LocalUidL()) );
       
   453     inParams.AppendL( calendarParam );
       
   454 
       
   455     // Append date param
       
   456     dateParam.Value().Set( activeDay );
       
   457     inParams.AppendL( dateParam );
       
   458 
       
   459     const TUid uid( TUid::Uid( KUidCalendarApplication ) );
       
   460     TAiwGenericParam uidParam( EGenericParamApplication );
       
   461     uidParam.Value().Set( uid );
       
   462     inParams.AppendL( uidParam );
       
   463 
       
   464     // Execute service command with given parameters
       
   465     iServiceHandler->ExecuteMenuCmdL( aCommand,
       
   466                                       inParams,
       
   467                                       iServiceHandler->OutParamListL(),
       
   468                                       0,
       
   469                                       NULL );
       
   470 
       
   471     }
       
   472 
       
   473 // ---------------------------------------------------------------------------
       
   474 // CESMRTrackingViewDialog::HandleFieldEventL
       
   475 // ---------------------------------------------------------------------------
       
   476 //
       
   477 void CESMRTrackingViewDialog::HandleFieldEventL(
       
   478         const MESMRFieldEvent& /*aEvent*/ )
       
   479     {
       
   480     FUNC_LOG;
       
   481     // From MESMRFieldEventObserver. Do nothing
       
   482     }
       
   483 
       
   484 // End of File
       
   485