meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrresponsefield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 8 e1b6206813b4
child 13 8592a65ad3fb
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Meeting Request viewer response field implementation
    14 * Description:  Meeting Request viewer response field implementation
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 #include "cesmrresponsefield.h"
    17 #include "cesmrresponsefield.h"
    19 #include "cesmrresponseitem.h"
    18 #include "cesmrresponseitem.h"
    20 #include "mesmrresponseobserver.h"
    19 #include "mesmrresponseobserver.h"
    21 #include "mesmrmeetingrequestentry.h"
    20 #include "mesmrmeetingrequestentry.h"
    22 #include "cesmrconflictpopup.h"
    21 #include "cesmrconflictpopup.h"
    23 #include "cesmrlayoutmgr.h"
       
    24 #include "nmrlayoutmanager.h"
    22 #include "nmrlayoutmanager.h"
    25 #include "esmrhelper.h"
    23 #include "esmrhelper.h"
    26 #include "cfsmailbox.h"
    24 #include "cfsmailcommon.h"
    27 
    25 
       
    26 #include "cesmrlistquery.h"
    28 #include <esmrgui.rsg>
    27 #include <esmrgui.rsg>
    29 #include <StringLoader.h>
    28 #include <stringloader.h>
    30 #include <calentry.h>
       
    31 #include <caluser.h>
    29 #include <caluser.h>
    32 
    30 
    33 // DEBUG
    31 // DEBUG
    34 #include "emailtrace.h"
    32 #include "emailtrace.h"
    35 
    33 
    36 /// Unnamed namespace for local definitions
    34 /// Unnamed namespace for local definitions
    37 namespace // codescanner::namespace 
    35 namespace
    38     { 
    36     {
    39     const TInt KSelectionTopic(0);
    37     const TInt KConflictItemIndex( 0 );
    40     const TInt KOnlyTwoLines( 2 );
    38     const TInt KExtraInfoItemIndex( 1 ); //"Request is out of date" "Please respond", ect
    41     const TInt KFirstCheckboxRow( 2 );
       
    42     const TInt KFirstControlItemIndex( 1 );
       
    43     const TInt KTopicFieldCount( 1 );
       
    44     const TInt KFirstSelectedItem( 1 );
       
    45     }  // namespace
    39     }  // namespace
    46 
    40 
    47 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    49 //                       CESMRResponseField
    43 //                       CESMRResponseField
    74 CESMRResponseField::~CESMRResponseField()
    68 CESMRResponseField::~CESMRResponseField()
    75     {
    69     {
    76     FUNC_LOG;
    70     FUNC_LOG;
    77     iResponseItemArray.ResetAndDestroy();
    71     iResponseItemArray.ResetAndDestroy();
    78     delete iConfPopup;
    72     delete iConfPopup;
    79     
    73 
    80     if( iESMRStaticAccessed ) 
    74     if( iESMRStaticAccessed )
    81         {
    75         {
    82         iESMRStatic.Close();
    76         iESMRStatic.Close();
    83         }
    77         }
    84     }
    78     }
    85 
    79 
    86 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    87 // CESMRResponseField::CESMRResponseField
    81 // CESMRResponseField::CESMRResponseField
    88 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    89 //
    83 //
    90 CESMRResponseField::CESMRResponseField(MESMRResponseObserver* aResponseObserver)
    84 CESMRResponseField::CESMRResponseField(MESMRResponseObserver* aResponseObserver)
    91 : iResponseObserver(aResponseObserver), iSelectionIndex( KFirstSelectedItem ),
    85 : iResponseObserver(aResponseObserver), iSelectionIndex( 0 ),
    92   iESMRStaticAccessed(EFalse)
    86   iESMRStaticAccessed(EFalse), iConflicted(EFalse)
    93     {
    87     {
    94     FUNC_LOG;
    88     FUNC_LOG;
    95     SetFieldId( EESMRFieldResponseArea );
    89     SetFieldId( EESMRFieldResponseArea );
    96     }
    90     }
    97 
    91 
   100 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
   101 //
    95 //
   102 void CESMRResponseField::ConstructL()
    96 void CESMRResponseField::ConstructL()
   103     {
    97     {
   104     FUNC_LOG;
    98     FUNC_LOG;
   105     // Construct the topic for response area
    99 
   106     // Topic line is without icon and text. Text is set later
   100     // Add pls resopond item to this field.
   107     CESMRResponseItem* responseItem =
   101     CESMRResponseItem* responseItem =
   108         CESMRResponseItem::NewLC( EESMRCmdUndefined, KNullDesC, EFalse );
   102         CESMRResponseItem::NewLC( EESMRCmdUndefined, KNullDesC, EFalse );
   109     iResponseItemArray.AppendL( responseItem );
   103     iResponseItemArray.AppendL( responseItem );
   110     CleanupStack::Pop( responseItem );
   104     CleanupStack::Pop( responseItem );
   111 
       
   112     // Create tick boxes only in non touch environment
       
   113     if ( !AknLayoutUtils::PenEnabled() )
       
   114     	{
       
   115 		// Constuct the first item (Accept)
       
   116 		HBufC* stringholder = StringLoader::LoadLC( R_QTN_MEET_REQ_RESPONSE_ACCEPT ,
       
   117 													iEikonEnv );
       
   118 		responseItem = CESMRResponseItem::NewLC( EESMRCmdAcceptMR, *stringholder, ETrue );
       
   119 		iResponseItemArray.AppendL( responseItem );
       
   120 		CleanupStack::Pop( responseItem );
       
   121 		CleanupStack::PopAndDestroy( stringholder );
       
   122 			
       
   123 		// Constuct the second item (Tentative)
       
   124 		stringholder = StringLoader::LoadLC( R_QTN_MEET_REQ_RESPONSE_TENTATIVE , iEikonEnv );
       
   125 		responseItem = CESMRResponseItem::NewLC( EESMRCmdTentativeMR, *stringholder, ETrue );
       
   126 		iResponseItemArray.AppendL( responseItem );
       
   127 		CleanupStack::Pop( responseItem );
       
   128 		CleanupStack::PopAndDestroy( stringholder );
       
   129 	
       
   130 		// Constuct the third item (Decline)
       
   131 		stringholder = StringLoader::LoadLC( R_QTN_MEET_REQ_RESPONSE_DECLINE , iEikonEnv );
       
   132 		responseItem = CESMRResponseItem::NewLC( EESMRCmdDeclineMR, *stringholder, ETrue );
       
   133 		iResponseItemArray.AppendL( responseItem );
       
   134 		CleanupStack::Pop( responseItem );
       
   135 		CleanupStack::PopAndDestroy( stringholder );
       
   136     	}
       
   137     }
   105     }
   138 
   106 
   139 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   140 // CESMRResponseField::InitializeL
   108 // CESMRResponseField::InitializeL
   141 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   142 //
   110 //
   143 void CESMRResponseField::InitializeL()
   111 void CESMRResponseField::InitializeL()
   144     {
   112     {
   145     FUNC_LOG;
   113     FUNC_LOG;
   146     TAknLayoutText layout = 
   114     TAknLayoutText layout =
   147     NMRLayoutManager::GetLayoutText( 
   115     NMRLayoutManager::GetLayoutText(
   148             Rect(), NMRLayoutManager::EMRTextLayoutCheckboxEditor );    
   116             Rect(), NMRLayoutManager::EMRTextLayoutCheckboxEditor );
   149     SetFont( layout.Font() );
   117     SetFont( layout.Font() );
   150     if( iSelectionIndex < iResponseItemArray.Count() )
       
   151         {
       
   152         iResponseItemArray[iSelectionIndex]->SetHighlight();
       
   153         }
       
   154     }
   118     }
   155 
   119 
   156 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   157 // CESMRResponseField::CountComponentControls
   121 // CESMRResponseField::CountComponentControls
   158 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   172     FUNC_LOG;
   136     FUNC_LOG;
   173     return iResponseItemArray[aInd];
   137     return iResponseItemArray[aInd];
   174     }
   138     }
   175 
   139 
   176 // -----------------------------------------------------------------------------
   140 // -----------------------------------------------------------------------------
   177 // CESMRResponseField::Draw
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CESMRResponseField::Draw(
       
   181     const TRect& /*aRect*/ ) const
       
   182     {
       
   183     FUNC_LOG;
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CESMRResponseField::SizeChanged
   141 // CESMRResponseField::SizeChanged
   188 // -----------------------------------------------------------------------------
   142 // -----------------------------------------------------------------------------
   189 //
   143 //
   190 void CESMRResponseField::SizeChanged()
   144 void CESMRResponseField::SizeChanged()
   191     {
   145     {
   192     FUNC_LOG;
   146     FUNC_LOG;
   193     TRect rect( Rect() );
   147     TInt count( iResponseItemArray.Count() );
   194 
       
   195     // Topic field
       
   196     TAknLayoutRect topicLayoutRect =
       
   197         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );  
       
   198     AknLayoutUtils::LayoutControl(
       
   199             ControlItem( KSelectionTopic ),
       
   200             rect,
       
   201             topicLayoutRect.Color().Value(), 
       
   202             topicLayoutRect.Rect().iTl.iX, 
       
   203             topicLayoutRect.Rect().iTl.iY, 
       
   204             topicLayoutRect.Rect().iBr.iX, 
       
   205             topicLayoutRect.Rect().iBr.iY,
       
   206             topicLayoutRect.Rect().Width(), 
       
   207             topicLayoutRect.Rect().Height());    
       
   208 
       
   209     // Items
       
   210     // Remove one for the topic field
       
   211     TInt count( iResponseItemArray.Count() - KTopicFieldCount );
       
   212     TInt row( KFirstCheckboxRow );
       
   213     TInt controlIndex( KFirstControlItemIndex );
       
   214     TRect parentRect( Rect() );
   148     TRect parentRect( Rect() );
   215     for( TInt i = 0; i < count; ++i )
   149     TRect rect;
   216         {        
   150     for( TInt i = 1; i <= count; ++i )
       
   151         {
   217         TAknLayoutRect choiceLayoutRect =
   152         TAknLayoutRect choiceLayoutRect =
   218             NMRLayoutManager::GetFieldRowLayoutRect( parentRect, row + i );
   153             NMRLayoutManager::GetFieldRowLayoutRect( parentRect, i );
   219         rect = parentRect;
   154         rect = parentRect;
   220         // Move the row down then it will be drawn to correct position.
   155         // Move the row down then it will be drawn to correct position.
   221         // controlIndex+1 tells the fields index.
   156         // controlIndex+1 tells the fields index.
   222         TInt movement = choiceLayoutRect.Rect().Height();
   157         TInt movement = choiceLayoutRect.Rect().Height();
   223         rect.Move( 0, movement * ( controlIndex + i ) );
   158         rect.Move( 0, movement * ( i - 1 ) );
   224         
   159 
   225         AknLayoutUtils::LayoutControl(
   160         AknLayoutUtils::LayoutControl(
   226                 ControlItem( controlIndex + i ),
   161                 ControlItem( i - 1 ),
   227                 rect,
   162                 rect,
   228                 choiceLayoutRect.Color().Value(), 
   163                 choiceLayoutRect.Color().Value(),
   229                 choiceLayoutRect.Rect().iTl.iX, 
   164                 choiceLayoutRect.Rect().iTl.iX,
   230                 choiceLayoutRect.Rect().iTl.iY, 
   165                 0,
   231                 choiceLayoutRect.Rect().iBr.iX, 
   166                 choiceLayoutRect.Rect().iBr.iX,
   232                 choiceLayoutRect.Rect().iBr.iY,
   167                 choiceLayoutRect.Rect().iBr.iY,
   233                 choiceLayoutRect.Rect().Width(), 
   168                 choiceLayoutRect.Rect().Width(),
   234                 choiceLayoutRect.Rect().Height() );          
   169                 choiceLayoutRect.Rect().Height() );
   235         }
   170         }
   236     }
   171     }
   237 
   172 
   238 // -----------------------------------------------------------------------------
   173 // -----------------------------------------------------------------------------
   239 // CESMRResponseField::MinimumSize
   174 // CESMRResponseField::MinimumSize
   245 
   180 
   246     // Topic field
   181     // Topic field
   247     TAknLayoutRect row1LayoutRect(
   182     TAknLayoutRect row1LayoutRect(
   248         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
   183         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
   249     rect = row1LayoutRect.Rect();
   184     rect = row1LayoutRect.Rect();
   250     
   185 
   251     TInt rowCount( iResponseItemArray.Count() );
   186     TInt rowCount( iResponseItemArray.Count() );
   252     TInt height( rect.Height() * rowCount );
   187     TInt height( rect.Height() * rowCount );
   253     return TSize( Parent()->Size().iWidth, height );
   188     return TSize( Parent()->Size().iWidth, height );
   254     }
   189     }
   255 
   190 
   259 //
   194 //
   260 TKeyResponse CESMRResponseField::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   195 TKeyResponse CESMRResponseField::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   261                                                 TEventCode aType )
   196                                                 TEventCode aType )
   262     {
   197     {
   263     FUNC_LOG;
   198     FUNC_LOG;
   264     TKeyResponse consumed( EKeyWasNotConsumed );    
   199     TKeyResponse consumed( EKeyWasNotConsumed );
   265 
   200 
   266     if ( aType == EEventKey && iSelectionIndex < iResponseItemArray.Count() )
   201     if ( aType == EEventKey )
   267         {
   202         {
   268         if ( aKeyEvent.iScanCode == EStdKeyUpArrow  && iSelectionIndex > 1)
   203         if ( iConflicted )
   269             {
   204             {
   270             iResponseItemArray[iSelectionIndex]->RemoveHighlight();
   205             if ( aKeyEvent.iScanCode == EStdKeyUpArrow  && iSelectionIndex > 0 )
   271             iSelectionIndex--;
   206                 {
   272             iResponseItemArray[iSelectionIndex]->SetHighlight();
   207                 iResponseItemArray[KExtraInfoItemIndex]->RemoveHighlight();
   273             consumed = EKeyWasConsumed;
   208                 iResponseItemArray[KConflictItemIndex]->SetHighlight();
   274             }
   209                 iSelectionIndex = KConflictItemIndex;
   275          if ( aKeyEvent.iScanCode == EStdKeyDownArrow  &&
   210                 consumed = EKeyWasConsumed;
   276               iSelectionIndex < iResponseItemArray.Count() - 1 )
   211                 }
   277             {
   212 
   278             iResponseItemArray[iSelectionIndex]->RemoveHighlight();
   213             if ( aKeyEvent.iScanCode == EStdKeyDownArrow  && iSelectionIndex < iResponseItemArray.Count()-1 )
   279             iSelectionIndex++;
   214                 {
   280             iResponseItemArray[iSelectionIndex]->SetHighlight();
   215                 iResponseItemArray[KConflictItemIndex]->RemoveHighlight();
   281             consumed = EKeyWasConsumed;
   216                 iResponseItemArray[KExtraInfoItemIndex]->SetHighlight();
   282             }
   217                 iSelectionIndex = KExtraInfoItemIndex;
   283          // If ok button is pressed and highlight is not in the topic item
   218                 consumed = EKeyWasConsumed;
   284          if ( aKeyEvent.iScanCode == EStdKeyDevice3
   219                 }
   285               && ItemSelectedL() )
       
   286             {
       
   287             consumed = EKeyWasConsumed;
       
   288             }
   220             }
   289         }
   221         }
   290 
   222 
   291     if ( consumed == EKeyWasConsumed )
   223     if ( consumed == EKeyWasConsumed )
   292         {
   224         {
   301 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   302 //
   234 //
   303 void CESMRResponseField::FocusChanged( TDrawNow /*aDrawNow*/ )
   235 void CESMRResponseField::FocusChanged( TDrawNow /*aDrawNow*/ )
   304     {
   236     {
   305     FUNC_LOG;
   237     FUNC_LOG;
       
   238     if ( iConflicted && !iPointEvent )
       
   239     	{
       
   240         // set the default value for iSelectionIndex, depend on iPreItemIndex
       
   241     	if ( PreItemIndex() <= CurrentItemIndex() )
       
   242     		{
       
   243             iSelectionIndex = 0;
       
   244     		}
       
   245     	else
       
   246     		{
       
   247             iSelectionIndex = 1;
       
   248     		}
       
   249     	}
   306     // Focus received
   250     // Focus received
   307     if ( IsFocused() && iSelectionIndex < iResponseItemArray.Count() )
   251     if ( IsFocused() && iSelectionIndex < iResponseItemArray.Count() )
   308         {
   252         {
   309         // By default, highlight the first item
   253         if( !iPointEvent )
   310         iResponseItemArray[iSelectionIndex]->SetHighlight();
   254         	{
   311         DrawDeferred();
   255             // By default, highlight the first item
   312         if (iConfPopup)
   256             iResponseItemArray[iSelectionIndex]->SetHighlight();
   313             {
   257             DrawDeferred();
   314             iConfPopup->ShowPopup();
   258         	}
   315             }
       
   316         }
   259         }
   317     else // Focus lost remove highlight
   260     else // Focus lost remove highlight
   318         {
   261         {
   319         for( TInt i = 0; i < iResponseItemArray.Count() ; i++ )
   262         for( TInt i = 0; i < iResponseItemArray.Count() ; i++ )
   320             {
   263             {
   321             iResponseItemArray[i]->RemoveHighlight();
   264             iResponseItemArray[i]->RemoveHighlight();
   322             }
   265             }
   323         }
   266         }
       
   267     iPointEvent = EFalse;
   324     }
   268     }
   325 
   269 
   326 // -----------------------------------------------------------------------------
   270 // -----------------------------------------------------------------------------
   327 // CESMRResponseField::InternalizeL
   271 // CESMRResponseField::InternalizeL
   328 // -----------------------------------------------------------------------------
   272 // -----------------------------------------------------------------------------
   329 //
   273 //
   330 void CESMRResponseField::InternalizeL( MESMRCalEntry& aEntry )
   274 void CESMRResponseField::InternalizeL( MESMRCalEntry& aEntry )
   331     {
   275     {
   332     FUNC_LOG;
   276     FUNC_LOG;
   333 
   277     iNormalResponse = EFalse;
       
   278     iRemoveResponse = EFalse;
   334     MESMRMeetingRequestEntry* entry = NULL;
   279     MESMRMeetingRequestEntry* entry = NULL;
   335     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == aEntry.Type() )
   280     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == aEntry.Type() )
   336         {
   281         {
   337         entry = static_cast<MESMRMeetingRequestEntry*>(&aEntry);
   282         entry = static_cast<MESMRMeetingRequestEntry*>(&aEntry);
   338         }
   283         }
   339     else
   284     else
   340         {
   285         {
   341         User::Leave( KErrNotSupported );
   286         User::Leave( KErrNotSupported );
   342         }
   287         }
   343 
   288 
       
   289     // Judge if there is any conflicts with other existed event.
       
   290     iConflicted = entry->Conflicts();
       
   291     if ( iConflicted )
       
   292         {
       
   293         // Construct the item to show conflicts info, and insert it to the beginning of array
       
   294         CESMRResponseItem* conflictItem =
       
   295             CESMRResponseItem::NewLC( EESMRCmdUndefined, KNullDesC, EFalse );
       
   296         iResponseItemArray.Insert( conflictItem, 0 );
       
   297         CleanupStack::Pop( conflictItem );
       
   298 
       
   299         HBufC* conflictString;
       
   300         conflictString = StringLoader::LoadLC(
       
   301                        R_QTN_MEET_REQ_RESPONSE_CONFLICT , iEikonEnv );
       
   302         // Show prompt conflict dialog
       
   303         iConfPopup = CESMRConflictPopup::NewL(aEntry);
       
   304 
       
   305         if ( iResponseItemArray.Count() > 0 )
       
   306             {
       
   307             iResponseItemArray[KConflictItemIndex]->SetUnderlineL( ETrue );
       
   308             iResponseItemArray[KConflictItemIndex]->SetTextL( conflictString->Des() );
       
   309             }
       
   310         CleanupStack::PopAndDestroy( conflictString );
       
   311         }
       
   312 
       
   313 
       
   314     // Set other info, for example, "please respond", "Request is out of date",
       
   315     // "Meeting has been canceled" ......
   344     MESMRMeetingRequestEntry::TESMREntryInfo attendeeInfo = entry->EntryAttendeeInfoL();
   316     MESMRMeetingRequestEntry::TESMREntryInfo attendeeInfo = entry->EntryAttendeeInfoL();
   345     HBufC* stringholder;
   317     HBufC* stringholder;
   346     switch( attendeeInfo )
   318     switch( attendeeInfo )
   347         {
   319         {
   348         case MESMRMeetingRequestEntry::EESMREntryInfoOutOfDate:
   320         case MESMRMeetingRequestEntry::EESMREntryInfoOutOfDate:
   349             {
   321             {
   350             stringholder = StringLoader::LoadLC(
   322             stringholder = StringLoader::LoadLC(
   351                            R_QTN_MEET_REQ_RESPONSE_OUT_OF_DATE , iEikonEnv );
   323                            R_QTN_MEET_REQ_RESPONSE_OUT_OF_DATE , iEikonEnv );
       
   324             if( entry->IsOpenedFromMail() )
       
   325             	{
       
   326                 iRemoveResponse = ETrue;
       
   327             	}
   352             break;
   328             break;
   353             }
   329             }
   354 
   330 
   355         case MESMRMeetingRequestEntry::EESMREntryInfoCancelled:
   331         case MESMRMeetingRequestEntry::EESMREntryInfoCancelled:
   356             {
   332             {
   357             stringholder = StringLoader::LoadLC(
   333             stringholder = StringLoader::LoadLC(
   358                            R_QTN_MEET_REQ_RESPONSE_CANCELLED , iEikonEnv );
   334                            R_QTN_MEET_REQ_RESPONSE_CANCELLED , iEikonEnv );
   359             HandleCancelledEventItemsL( aEntry );
   335             HandleCancelledEventItemsL( aEntry );
       
   336             if( entry->IsOpenedFromMail() )
       
   337             	{
       
   338             	iRemoveResponse = ETrue;
       
   339             	}
   360             break;
   340             break;
   361             }
   341             }
   362 
   342 
   363         case MESMRMeetingRequestEntry::EESMREntryInfoAccepted:
   343         case MESMRMeetingRequestEntry::EESMREntryInfoAccepted:
   364             {
   344             {
   365             stringholder = StringLoader::LoadLC(
   345             stringholder = StringLoader::LoadLC(
   366                            R_QTN_MEET_REQ_RESPOND_ACCEPTED , iEikonEnv );
   346                            R_QTN_MEET_REQ_RESPOND_ACCEPTED , iEikonEnv );
       
   347             iNormalResponse = ETrue;
   367             break;
   348             break;
   368             }
   349             }
   369 
   350 
   370         case MESMRMeetingRequestEntry::EESMREntryInfoTentativelyAccepted:
   351         case MESMRMeetingRequestEntry::EESMREntryInfoTentativelyAccepted:
   371             {
   352             {
   372             stringholder = StringLoader::LoadLC(
   353             stringholder = StringLoader::LoadLC(
   373                            R_QTN_MEET_REQ_RESPOND_TENTATIVE , iEikonEnv );
   354                            R_QTN_MEET_REQ_RESPOND_TENTATIVE , iEikonEnv );
       
   355             iNormalResponse = ETrue;
   374             break;
   356             break;
   375             }
   357             }
   376 
   358 
   377         case MESMRMeetingRequestEntry::EESMREntryInfoDeclined:
   359         case MESMRMeetingRequestEntry::EESMREntryInfoDeclined:
   378             {
   360             {
   379             stringholder = StringLoader::LoadLC(
   361             stringholder = StringLoader::LoadLC(
   380                            R_QTN_MEET_REQ_RESPOND_DECLINED , iEikonEnv );
   362                            R_QTN_MEET_REQ_RESPOND_DECLINED , iEikonEnv );
       
   363             iNormalResponse = ETrue;
   381             break;
   364             break;
   382             }
   365             }
   383 
   366 
   384        case MESMRMeetingRequestEntry::EESMREntryInfoOccursInPast:
   367        case MESMRMeetingRequestEntry::EESMREntryInfoOccursInPast:
   385             {
   368             {
   386             stringholder = StringLoader::LoadLC(
   369             stringholder = StringLoader::LoadLC(
   387                            R_QTN_MEET_REQ_RESPONSE_OCCURS_PAST , iEikonEnv );
   370                            R_QTN_MEET_REQ_RESPONSE_OCCURS_PAST , iEikonEnv );
       
   371             if( entry->IsOpenedFromMail() )
       
   372             	{
       
   373             	iRemoveResponse = ETrue;
       
   374             	}
   388             break;
   375             break;
   389             }
   376             }
   390 
   377 
   391         case MESMRMeetingRequestEntry::EESMREntryInfoConflicts:
   378         case MESMRMeetingRequestEntry::EESMREntryInfoNormal:
   392             {
   379             {
   393             stringholder = StringLoader::LoadLC(
   380             stringholder = StringLoader::LoadLC(
   394                            R_QTN_MEET_REQ_RESPONSE_CONFLICT , iEikonEnv );
   381                            R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND , iEikonEnv );
   395             iConfPopup = CESMRConflictPopup::NewL(aEntry);
   382             iNormalResponse = ETrue;
   396             iConfPopup->ShowPopup();
       
   397             break;
   383             break;
   398             }
   384             }
   399 
   385 
   400         case MESMRMeetingRequestEntry::EESMREntryInfoNormal:
   386         default:
   401             {
       
   402             stringholder = StringLoader::LoadLC(
   387             stringholder = StringLoader::LoadLC(
   403                            R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND , iEikonEnv );
   388                            R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND , iEikonEnv );
   404             break;
   389             iNormalResponse = ETrue;
   405             }
       
   406 
       
   407         default:
       
   408         stringholder = StringLoader::LoadLC(
       
   409                        R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND , iEikonEnv );
       
   410         break;
   390         break;
   411         }
   391         }
   412 
   392 
   413     iResponseItemArray[0]->SetTextL( stringholder->Des() );
   393     TInt repondItemIndex( 0 );
   414     // Check do we need to expand because of the long topic text ( two lines max )
   394     if ( iConflicted && iResponseItemArray.Count() == 2 )
   415     if ( iResponseItemArray[0]->ItemTextLineCount() > 1  ||
   395         {
   416             iResponseItemArray.Count() == KOnlyTwoLines )
   396         repondItemIndex = 1;
   417         {
   397         }
   418         SizeChanged();
   398 
   419         }
   399     iResponseItemArray[repondItemIndex]->SetUnderlineL( ETrue );
       
   400     iResponseItemArray[repondItemIndex]->SetTextL( stringholder->Des() );
       
   401 
       
   402     SizeChanged();
   420     CleanupStack::PopAndDestroy( stringholder );
   403     CleanupStack::PopAndDestroy( stringholder );
   421     }
   404     }
   422 
   405 
   423 // -----------------------------------------------------------------------------
   406 // -----------------------------------------------------------------------------
   424 // CESMRResponseField::AddObserver
   407 // CESMRResponseField::AddObserver
   436 //
   419 //
   437 void CESMRResponseField::SetFont( const CFont* aFont )
   420 void CESMRResponseField::SetFont( const CFont* aFont )
   438     {
   421     {
   439     FUNC_LOG;
   422     FUNC_LOG;
   440     iFont = aFont;
   423     iFont = aFont;
   441     // Set font for the response items (Tpoic, Accept, Tentative, Decline )
   424     // Set font for the response items (conflict and extrainfo item )
   442     TInt itemCount = iResponseItemArray.Count();
   425     TInt itemCount = iResponseItemArray.Count();
   443     for( TInt i = 0; i < itemCount; i++ )
   426     for( TInt i = 0; i < itemCount; i++ )
   444         {
   427         {
   445         iResponseItemArray[i]->SetFont( aFont );
   428         iResponseItemArray[i]->SetFont( aFont );
   446         }
   429         }
   447     }
   430     }
   448 
   431 
   449 // -----------------------------------------------------------------------------
   432 // -----------------------------------------------------------------------------
   450 // CESMRResponseField::SetLayoutManager
       
   451 // -----------------------------------------------------------------------------
       
   452 //
       
   453 void CESMRResponseField::SetLayoutManager( CESMRLayoutManager* aLayout )
       
   454     {
       
   455     FUNC_LOG;
       
   456     iLayout = aLayout;
       
   457 
       
   458     // Set layoutmanager for the response items
       
   459     TInt itemCount = iResponseItemArray.Count();
       
   460     for( TInt i = 0; i < itemCount; i++ )
       
   461         {
       
   462         iResponseItemArray[i]->SetLayoutManager( aLayout );
       
   463         }
       
   464     }
       
   465 
       
   466 // -----------------------------------------------------------------------------
       
   467 // CESMRResponseField::ItemSelectedL
   433 // CESMRResponseField::ItemSelectedL
   468 // -----------------------------------------------------------------------------
   434 // -----------------------------------------------------------------------------
   469 //
   435 //
   470 TBool CESMRResponseField::ItemSelectedL()
   436 TBool CESMRResponseField::ItemSelectedL()
   471     {
   437     {
   472     FUNC_LOG;
   438     FUNC_LOG;
   473     TBool selected( EFalse );
   439     TBool selected( EFalse );
   474     
   440     TInt ret( KErrCancel );
   475     if ( iSelectionIndex > KSelectionTopic )
   441 
   476         {
   442     if ( iConflicted )
   477         if( iSelectionIndex < iResponseItemArray.Count() )
   443         {
   478             {
   444         if ( iSelectionIndex == 0 )
   479             iResponseItemArray[iSelectionIndex]->ChangeIconL( ETrue );
   445             {
   480             }
   446             if ( iConfPopup )
   481         // Redraw to enable new checked icon in the screen
   447                 {
   482         DrawDeferred();
   448                 iConfPopup->ShowPopup();
   483                 
   449                 }
   484         TBool response( EFalse );
   450             }
   485         
   451 
   486         TInt cmd( 0 );
   452         if ( KExtraInfoItemIndex == iSelectionIndex )
   487         if( iSelectionIndex < iResponseItemArray.Count() )
   453             {
   488             {
   454             if ( iNormalResponse )
   489             cmd = static_cast< TInt >( iResponseItemArray[iSelectionIndex]->CommandId() );
   455                 {
   490             }
   456                 // Try to send response
   491         response = iResponseObserver->Response( cmd );
   457                 CESMRListQuery* query =
   492         
   458                         CESMRListQuery::NewL( CESMRListQuery::EESMRNormalResponseQuery );
   493         if ( !response )
   459                 CleanupStack::PushL( query );
   494             {
   460                 ret = query->ExecuteLD();
   495             // Cancel was selected, update the icon
   461                 CleanupStack::Pop( query );
   496             if( iSelectionIndex < iResponseItemArray.Count() )
   462                 }
   497                 {
   463             if ( iRemoveResponse )
   498                 iResponseItemArray[iSelectionIndex]->ChangeIconL( EFalse );
   464                 {
   499                 }
   465                 CESMRListQuery* query =
   500             }
   466                         CESMRListQuery::NewL( CESMRListQuery::EESMRRemoveResponseQuery );
   501         
   467                 CleanupStack::PushL( query );
   502         selected = ETrue;
   468                 ret = query->ExecuteLD();
   503         }
   469                 CleanupStack::Pop( query );
   504     
   470                 }
       
   471             }
       
   472         }
       
   473     else
       
   474         {
       
   475         if ( KConflictItemIndex == iSelectionIndex )
       
   476             {
       
   477             if ( iNormalResponse )
       
   478                 {
       
   479                 // Try to send response
       
   480                 CESMRListQuery* query =
       
   481                         CESMRListQuery::NewL( CESMRListQuery::EESMRNormalResponseQuery );
       
   482                 CleanupStack::PushL( query );
       
   483                 ret = query->ExecuteLD();
       
   484                 CleanupStack::Pop( query );
       
   485                 }
       
   486             if ( iRemoveResponse )
       
   487                 {
       
   488                 CESMRListQuery* query =
       
   489                         CESMRListQuery::NewL( CESMRListQuery::EESMRRemoveResponseQuery );
       
   490                 CleanupStack::PushL( query );
       
   491                 ret = query->ExecuteLD();
       
   492                 CleanupStack::Pop( query );
       
   493                 }
       
   494             }
       
   495         }
       
   496 
       
   497     if ( KErrCancel != ret )
       
   498         {
       
   499         NotifyEventAsyncL( ret );
       
   500         }
       
   501 
   505     return selected;
   502     return selected;
   506     }
   503     }
   507 
   504 
   508 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------
   509 // CESMRResponseField::HandleCancelledEventItemsL
   506 // CESMRResponseField::HandleCancelledEventItemsL
   510 // -----------------------------------------------------------------------------
   507 // -----------------------------------------------------------------------------
   511 //
   508 //
   512 void CESMRResponseField::HandleCancelledEventItemsL( MESMRCalEntry& aEntry )
   509 void CESMRResponseField::HandleCancelledEventItemsL( MESMRCalEntry& aEntry )
   513     {
   510     {
   514     FUNC_LOG;
   511     FUNC_LOG;
   515     // Remove all other but title items from response array. Only 'Remove from Cal'
       
   516     // should be shown.
       
   517     TInt count = iResponseItemArray.Count();
       
   518     for ( TInt i = count - 1; i > 0; --i )
       
   519         {
       
   520         CESMRResponseItem* item = iResponseItemArray[i];
       
   521         iResponseItemArray.Remove( i );
       
   522         delete item;
       
   523         item = NULL;
       
   524         }
       
   525 
       
   526     CCalEntry& entry = aEntry.Entry();
   512     CCalEntry& entry = aEntry.Entry();
   527     CCalUser* calUser = entry.PhoneOwnerL();
   513     CCalUser* calUser = entry.PhoneOwnerL();
   528     TPtrC addr = ESMRHelper::AddressWithoutMailtoPrefix( calUser->Address() );
   514     TPtrC addr = ESMRHelper::AddressWithoutMailtoPrefix( calUser->Address() );
   529     
   515 
   530     iESMRStatic.ConnectL();
   516     iESMRStatic.ConnectL();
   531     iESMRStaticAccessed = ETrue;
   517     iESMRStaticAccessed = ETrue;
   532     
       
   533     if( iESMRStatic.MailBoxL( addr ).HasCapability( 
       
   534             EFSMBoxCapaRemoveFromCalendar ) &&
       
   535             aEntry.IsStoredL() )
       
   536         {
       
   537         // Construct the 'Remove from Calendar' item
       
   538         HBufC* stringholder = StringLoader::LoadLC(
       
   539                 R_QTN_MEET_REQ_RESPONSE_REMOVE_CALENDAR_EVENT, iEikonEnv );
       
   540         CESMRResponseItem* responseItem =
       
   541             CESMRResponseItem::NewL( EESMRCmdRemoveFromCalendar, *stringholder, ETrue );
       
   542         CleanupStack::PopAndDestroy( stringholder );
       
   543         CleanupStack::PushL( responseItem );
       
   544         // Set layout manager and font for the item
       
   545         responseItem->SetLayoutManager( iLayout );
       
   546         responseItem->SetFont( iFont );
       
   547         responseItem->SetHighlight();
       
   548         User::LeaveIfError( iResponseItemArray.Append( responseItem ) );
       
   549         CleanupStack::Pop( responseItem );
       
   550         }
       
   551     }
   518     }
   552 
   519 
   553 // -----------------------------------------------------------------------------
   520 // -----------------------------------------------------------------------------
   554 // CESMRResponseField::ExecuteGenericCommandL
   521 // CESMRResponseField::ExecuteGenericCommandL
   555 // -----------------------------------------------------------------------------
   522 // -----------------------------------------------------------------------------
   556 //
   523 //
   557 void CESMRResponseField::ExecuteGenericCommandL( TInt aCommand )
   524 TBool CESMRResponseField::ExecuteGenericCommandL( TInt aCommand )
   558     {
   525     {
   559     FUNC_LOG;
   526     FUNC_LOG;
       
   527     TBool isUsed( EFalse );
   560     if ( aCommand == EAknSoftkeySelect )
   528     if ( aCommand == EAknSoftkeySelect )
   561         {
   529         {
   562         ItemSelectedL();
   530         ItemSelectedL();
       
   531         isUsed = ETrue;
   563         }
   532         }
   564     else
   533     else
   565         {
   534         {
   566         CESMRField::ExecuteGenericCommandL( aCommand );
   535         isUsed = CESMRField::ExecuteGenericCommandL( aCommand );
   567         }
   536         }
       
   537 
       
   538     return isUsed;
   568     }
   539     }
   569 
   540 
   570 // -----------------------------------------------------------------------------
   541 // -----------------------------------------------------------------------------
   571 // CESMRResponseField::SetOutlineFocusL
   542 // CESMRResponseField::SetOutlineFocusL
   572 // -----------------------------------------------------------------------------
   543 // -----------------------------------------------------------------------------
   573 //
   544 //
   574 void CESMRResponseField::SetOutlineFocusL( TBool aFocus )
   545 void CESMRResponseField::SetOutlineFocusL( TBool aFocus )
   575     {
   546     {
   576     FUNC_LOG;
   547     FUNC_LOG;
   577     CESMRField::SetOutlineFocusL( aFocus );
   548     CESMRField::SetOutlineFocusL( aFocus );
   578     
   549 
   579     if ( aFocus )
   550     if ( aFocus )
   580         {
   551         {
   581         SetMiddleSoftKeyVisible( ETrue );
   552         SetMiddleSoftKeyVisible( ETrue );
   582         }
   553         }
       
   554     }
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // CESMRResponseField::HandleSingletapEventL
       
   558 // -----------------------------------------------------------------------------
       
   559 //
       
   560 TBool CESMRResponseField::HandleSingletapEventL( const TPoint& aPosition )
       
   561     {
       
   562     FUNC_LOG;
       
   563 
       
   564     TBool handled( EFalse );
       
   565     if( !iLongTapEventConsumed )
       
   566         {
       
   567         handled = HandleTapEventL( aPosition );
       
   568         }
       
   569     iLongTapEventConsumed = EFalse;
       
   570 
       
   571     return handled;
       
   572     }
       
   573 
       
   574 // ---------------------------------------------------------------------------
       
   575 // CESMRResponseField::HandleLongtapEventL
       
   576 // ---------------------------------------------------------------------------
       
   577 //
       
   578 void CESMRResponseField::HandleLongtapEventL( const TPoint& aPosition )
       
   579     {
       
   580     FUNC_LOG;
       
   581     HandleTapEventL( aPosition );
       
   582     }
       
   583 
       
   584 // ---------------------------------------------------------------------------
       
   585 // CESMRResponseField::HandletapEventL
       
   586 // ---------------------------------------------------------------------------
       
   587 //
       
   588 TBool CESMRResponseField::HandleTapEventL( const TPoint& aPosition )
       
   589     {
       
   590     TBool handled = EFalse;
       
   591     TInt ret = KErrCancel;
       
   592 
       
   593     if ( Rect().Contains( aPosition ) )
       
   594         {
       
   595         if ( iConflicted )
       
   596             {
       
   597             TRect conflictItemRect = iResponseItemArray[KConflictItemIndex]->Rect();
       
   598             if ( conflictItemRect.Contains( aPosition ) )
       
   599                 {
       
   600                 iResponseItemArray[KExtraInfoItemIndex]->RemoveHighlight();
       
   601                 iResponseItemArray[KConflictItemIndex]->SetHighlight();
       
   602                 iSelectionIndex = KConflictItemIndex;
       
   603                  if ( iConfPopup )
       
   604                     {
       
   605                     iLongTapEventConsumed = ETrue;
       
   606                     iConfPopup->ShowPopup();
       
   607                     }
       
   608                 }
       
   609             else
       
   610                 {
       
   611                 iResponseItemArray[KConflictItemIndex]->RemoveHighlight();
       
   612                 iResponseItemArray[KExtraInfoItemIndex]->SetHighlight();
       
   613                 iSelectionIndex = KExtraInfoItemIndex;
       
   614                 DrawDeferred();
       
   615                 if ( iNormalResponse )
       
   616                     {
       
   617                     CESMRListQuery* query =
       
   618                             CESMRListQuery::NewL( CESMRListQuery::EESMRNormalResponseQuery );
       
   619                     CleanupStack::PushL( query );
       
   620                     // Use this flag to avoid the same event be handled by
       
   621                     // HandleSingletapEventL() when HandleLongtapEventL().
       
   622                     iLongTapEventConsumed = ETrue;
       
   623                     ret = query->ExecuteLD();
       
   624                     CleanupStack::Pop( query );
       
   625                     }
       
   626                 if ( iRemoveResponse )
       
   627                     {
       
   628                     CESMRListQuery* query =
       
   629                             CESMRListQuery::NewL( CESMRListQuery::EESMRRemoveResponseQuery );
       
   630                     CleanupStack::PushL( query );
       
   631                     iLongTapEventConsumed = ETrue;
       
   632                     ret = query->ExecuteLD();
       
   633                     CleanupStack::Pop( query );
       
   634                     }
       
   635                 }
       
   636             }
       
   637         else
       
   638             {
       
   639             iResponseItemArray[0]->SetHighlight();
       
   640             if ( iNormalResponse )
       
   641                 {
       
   642                 CESMRListQuery* query =
       
   643                         CESMRListQuery::NewL( CESMRListQuery::EESMRNormalResponseQuery );
       
   644                 CleanupStack::PushL( query );
       
   645                 iLongTapEventConsumed = ETrue;
       
   646                 ret = query->ExecuteLD();
       
   647                 CleanupStack::Pop( query );
       
   648                 }
       
   649 
       
   650             if ( iRemoveResponse )
       
   651                 {
       
   652                 CESMRListQuery* query =
       
   653                         CESMRListQuery::NewL( CESMRListQuery::EESMRRemoveResponseQuery );
       
   654                 CleanupStack::PushL( query );
       
   655                 iLongTapEventConsumed = ETrue;
       
   656                 ret = query->ExecuteLD();
       
   657                 CleanupStack::Pop( query );
       
   658                 }
       
   659             }
       
   660 
       
   661         DrawDeferred();
       
   662 
       
   663         handled = ETrue;
       
   664         iPointEvent = ETrue;
       
   665 
       
   666         if ( KErrCancel != ret )
       
   667             {
       
   668             NotifyEventAsyncL( ret );
       
   669             }
       
   670 
       
   671         }
       
   672 
       
   673     return handled;
   583     }
   674     }
   584 
   675 
   585 // -----------------------------------------------------------------------------
   676 // -----------------------------------------------------------------------------
   586 // CESMRResponseField::ControlItem
   677 // CESMRResponseField::ControlItem
   587 // -----------------------------------------------------------------------------
   678 // -----------------------------------------------------------------------------
   591     CCoeControl* control = NULL;
   682     CCoeControl* control = NULL;
   592     if( aIndex < iResponseItemArray.Count() )
   683     if( aIndex < iResponseItemArray.Count() )
   593         {
   684         {
   594         control = static_cast<CCoeControl*>( iResponseItemArray[aIndex] );
   685         control = static_cast<CCoeControl*>( iResponseItemArray[aIndex] );
   595         }
   686         }
   596         
   687 
   597     return control;
   688     return control;
   598     }
   689     }
   599 
   690 
   600 // EOF
   691 // EOF
   601 
   692