meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrresponsereadyfield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 11 0396474f30f5
child 13 8592a65ad3fb
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     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: This file implements class CESMRResponseReadyField.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "cesmrresponsereadyfield.h"
       
    21 #include "mesmrmeetingrequestentry.h"
       
    22 #include "mesmrresponseobserver.h"
       
    23 #include <esmrgui.rsg>
       
    24 
       
    25 #include <eiklabel.h>
       
    26 #include <caluser.h>
       
    27 #include <calalarm.h>
       
    28 #include <avkon.rsg>
       
    29 #include <calentry.h>
       
    30 #include <eikenv.h>
       
    31 #include <eikedwin.h>
       
    32 #include <StringLoader.h>
       
    33 #include <AknUtils.h>
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CESMRResponseReadyField::CESMRResponseReadyField
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CESMRResponseReadyField::CESMRResponseReadyField(
       
    42         MESMRResponseObserver* aResponseObserver )
       
    43 :   iResponseObserver(aResponseObserver)
       
    44     {
       
    45     FUNC_LOG;
       
    46     //do nothing
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CESMRResponseReadyField::~CESMRResponseReadyField
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CESMRResponseReadyField::~CESMRResponseReadyField()
       
    54     {
       
    55     FUNC_LOG;
       
    56     //do nothing
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CESMRResponseReadyField::CESMRResponseReadyField
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CESMRResponseReadyField* CESMRResponseReadyField::NewL(
       
    64         MESMRResponseObserver* aResponseObserver )
       
    65     {
       
    66     FUNC_LOG;
       
    67     CESMRResponseReadyField* self =
       
    68             new (ELeave) CESMRResponseReadyField( aResponseObserver );
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop( self );
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CESMRResponseReadyField::ConstructL
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CESMRResponseReadyField::ConstructL()
       
    80     {
       
    81     FUNC_LOG;
       
    82     iLabel = new (ELeave) CEikLabel;
       
    83     iLabel->SetTextL( KNullDesC );
       
    84     SetFieldId( EESMRFieldResponseReadyArea );
       
    85     CESMRField::ConstructL( iLabel, EESMRHighlightFocus );
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CESMRResponseReadyField::InitializeL
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CESMRResponseReadyField::InitializeL()
       
    93     {
       
    94     FUNC_LOG;
       
    95     iLabel->SetFont( iLayout->Font( iCoeEnv, iFieldId ));
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CESMRResponseReadyField::InternalizeL
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CESMRResponseReadyField::InternalizeL(
       
   103         MESMRCalEntry& aEntry )
       
   104     {
       
   105     FUNC_LOG;
       
   106     MESMRMeetingRequestEntry* entry = NULL;
       
   107     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == aEntry.Type() )
       
   108         {
       
   109         entry = static_cast<MESMRMeetingRequestEntry*>(&aEntry);
       
   110         }
       
   111     else
       
   112         {
       
   113         User::Leave( KErrNotSupported );
       
   114         }
       
   115 
       
   116     TInt attendeeInfo = entry->EntryAttendeeInfoL();
       
   117     HBufC* stringholder = NULL;
       
   118     switch( attendeeInfo )
       
   119         {
       
   120         case MESMRMeetingRequestEntry::EESMREntryInfoOutOfDate:
       
   121             {
       
   122             stringholder = StringLoader::LoadLC(
       
   123                             R_QTN_MEET_REQ_RESPONSE_OUT_OF_DATE,
       
   124                             iEikonEnv );
       
   125             }
       
   126             break;
       
   127         case MESMRMeetingRequestEntry::EESMREntryInfoCancelled:
       
   128             {
       
   129             stringholder = StringLoader::LoadLC(
       
   130                             R_QTN_MEET_REQ_RESPONSE_CANCELLED,
       
   131                             iEikonEnv );
       
   132             }
       
   133             break;
       
   134         case MESMRMeetingRequestEntry::EESMREntryInfoAccepted:
       
   135             {
       
   136             stringholder = StringLoader::LoadLC(
       
   137                             R_QTN_MEET_REQ_RESPOND_ACCEPTED,
       
   138                             iEikonEnv );
       
   139             }
       
   140             break;
       
   141         case MESMRMeetingRequestEntry::EESMREntryInfoTentativelyAccepted:
       
   142             {
       
   143             stringholder = StringLoader::LoadLC(
       
   144                             R_QTN_MEET_REQ_RESPOND_TENTATIVE,
       
   145                             iEikonEnv );
       
   146             }
       
   147             break;
       
   148         case MESMRMeetingRequestEntry::EESMREntryInfoDeclined:
       
   149             {
       
   150             stringholder = StringLoader::LoadLC(
       
   151                             R_QTN_MEET_REQ_RESPOND_DECLINED,
       
   152                             iEikonEnv );
       
   153             }
       
   154             break;
       
   155         case MESMRMeetingRequestEntry::EESMREntryInfoOccursInPast:
       
   156             {
       
   157             stringholder = StringLoader::LoadLC(
       
   158                             R_QTN_MEET_REQ_RESPONSE_OCCURS_PAST,
       
   159                             iEikonEnv );
       
   160             }
       
   161             break;
       
   162         case MESMRMeetingRequestEntry::EESMREntryInfoConflicts:
       
   163             {
       
   164             stringholder = StringLoader::LoadLC(
       
   165                             R_QTN_MEET_REQ_RESPONSE_CONFLICT,
       
   166                             iEikonEnv );
       
   167             }
       
   168             break;
       
   169         case MESMRMeetingRequestEntry::EESMREntryInfoNormal:
       
   170             {
       
   171             stringholder = StringLoader::LoadLC(
       
   172                             R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND,
       
   173                             iEikonEnv );
       
   174             }
       
   175             break;
       
   176         default:
       
   177             {
       
   178             User::Leave( KErrNotSupported );
       
   179             break;
       
   180             }
       
   181         }
       
   182 
       
   183     iLabel->SetTextL( *stringholder );
       
   184     CleanupStack::PopAndDestroy( stringholder );
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CESMRResponseReadyField::OfferKeyEventL
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TKeyResponse CESMRResponseReadyField::OfferKeyEventL(
       
   192         const TKeyEvent& aEvent,
       
   193         TEventCode aType)
       
   194     {
       
   195     FUNC_LOG;
       
   196     TKeyResponse response = EKeyWasNotConsumed;
       
   197     
       
   198     if( aType == EEventKey )
       
   199         {
       
   200         if( aEvent.iScanCode == EStdKeyDevice3 )
       
   201             {
       
   202             iResponseObserver->ChangeReadyResponseL();
       
   203             response = EKeyWasConsumed;
       
   204             }
       
   205         }
       
   206     return response;
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // CESMRResponseReadyField::SetOutlineFocusL
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CESMRResponseReadyField::SetOutlineFocusL( TBool aFocus )
       
   214     {
       
   215     FUNC_LOG;
       
   216     CESMRField::SetOutlineFocusL( aFocus );
       
   217 
       
   218     TRgb fontColor( 0, 0, 0 );
       
   219     if ( aFocus )
       
   220         {
       
   221         SetMiddleSoftKeyVisible( ETrue );
       
   222         fontColor = iLayout->ViewerListAreaHighlightedTextColor();
       
   223         }
       
   224     else
       
   225         {
       
   226         fontColor = iLayout->ViewerListAreaTextColor();
       
   227         }
       
   228 
       
   229     AknLayoutUtils::OverrideControlColorL( *iLabel,
       
   230                                       EColorLabelText,
       
   231                                            fontColor );
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // CESMRResponseReadyField::SetOutlineFocusL
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 void CESMRResponseReadyField::ExecuteGenericCommandL( TInt aCommand )
       
   239     {
       
   240     FUNC_LOG;
       
   241     if ( aCommand == EAknSoftkeySelect )
       
   242         {
       
   243         iResponseObserver->ChangeReadyResponseL();
       
   244         }
       
   245     }
       
   246