meetingrequest/mrgui/src/cesmrviewerfieldstorage.cpp
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 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 : Storage for viewer fields
       
    15 *  Version     : %version: e002sa33#8 %
       
    16 *
       
    17 */
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "cesmrviewerfieldstorage.h"
       
    21 
       
    22 //<cmail>
       
    23 #include "cesmrpolicy.h"
       
    24 //</cmail>
       
    25 
       
    26 #include "cesmrfield.h"
       
    27 
       
    28 // <cmail> Removed profiling. </cmail>
       
    29 
       
    30 /// Unnamed namespace for local definitions
       
    31 namespace { // codescanner::namespace
       
    32 
       
    33 const TInt KRequiredLabel = 0;
       
    34 const TInt KStatusField = 1;
       
    35 const TInt KOptionalLabel = 2;
       
    36 
       
    37 }//namespace
       
    38 
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CESMRViewerFieldStorage::CESMRViewerFieldStorage
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CESMRViewerFieldStorage::CESMRViewerFieldStorage(
       
    46         MESMRFieldEventObserver& aEventObserver )
       
    47     : CESMRFieldStorage( aEventObserver )
       
    48     {
       
    49     FUNC_LOG;
       
    50     // Do nothing
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CESMRViewerFieldStorage::~CESMRViewerFieldStorage
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CESMRViewerFieldStorage::~CESMRViewerFieldStorage()
       
    58     {
       
    59     FUNC_LOG;
       
    60     // Do nothing
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CESMRViewerFieldStorage::NewL
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CESMRViewerFieldStorage* CESMRViewerFieldStorage::NewL(
       
    68         const CESMRPolicy& aPolicy,
       
    69         MESMRResponseObserver* aResponseObserver,
       
    70         TBool aResponseReady,
       
    71         MESMRFieldEventObserver& aEventObserver,
       
    72         TInt aReqAttendee,
       
    73         TInt aOptAttendee )
       
    74     {
       
    75     FUNC_LOG;
       
    76     CESMRViewerFieldStorage* self =
       
    77             new (ELeave) CESMRViewerFieldStorage( aEventObserver );
       
    78     CleanupStack::PushL( self );
       
    79     self->ConstructL( aPolicy, aResponseObserver, 
       
    80 					  aResponseReady , aReqAttendee, 
       
    81 					  aOptAttendee);
       
    82     CleanupStack::Pop( self );
       
    83     return self;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CESMRViewerFieldStorage::ConstructL
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CESMRViewerFieldStorage::ConstructL(
       
    91         const CESMRPolicy& aPolicy,
       
    92         MESMRResponseObserver* aResponseObserver,
       
    93         TBool aResponseReady,
       
    94         const TInt &aReqAttendee,
       
    95         const TInt &aOptAttendee
       
    96         )
       
    97     {
       
    98     FUNC_LOG;
       
    99     CESMRFieldStorage::BaseConstructL();
       
   100     
       
   101     if ( (aReqAttendee == 0) && (aOptAttendee ==0) )
       
   102         {
       
   103         CreatePolicyFieldsL (aPolicy,aResponseObserver, aResponseReady);
       
   104         }
       
   105     else// Total field count is given Tracking dialog
       
   106         {
       
   107         CreateTrackingFieldsL( aPolicy,
       
   108 							   aResponseObserver, 
       
   109 							   aResponseReady,
       
   110 							   aReqAttendee,
       
   111 							   aOptAttendee);
       
   112         }
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CESMRViewerFieldStorage::ExternalizeL
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CESMRViewerFieldStorage::ExternalizeL(
       
   120         MESMRCalEntry& aEntry )
       
   121     {
       
   122     FUNC_LOG;
       
   123     CESMRFieldStorage::ExternalizeL( aEntry );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CESMRViewerFieldStorage::CreatePolicyFieldsL
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CESMRViewerFieldStorage::CreatePolicyFieldsL(
       
   131         const CESMRPolicy& aPolicy,
       
   132         MESMRResponseObserver* aResponseObserver,
       
   133         TBool aResponseReady)
       
   134     {
       
   135     FUNC_LOG;
       
   136     CESMRField* field = NULL;
       
   137     
       
   138     RArray<TESMREntryField> fields = aPolicy.Fields();
       
   139     const TInt count = fields.Count();
       
   140     for ( TInt i(0); i < count ; i++ )
       
   141         {
       
   142         field = CreateViewerFieldL( 
       
   143         		aResponseObserver, fields[i], aResponseReady );
       
   144 
       
   145         TBool visible( ETrue );
       
   146                    
       
   147         CleanupStack::PushL( field );
       
   148         AddFieldL( field, visible );
       
   149         CleanupStack::Pop( field );
       
   150         }
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CESMRViewerFieldStorage::CreateTrackingFieldsL
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CESMRViewerFieldStorage::CreateTrackingFieldsL(
       
   158         const CESMRPolicy& aPolicy,
       
   159         MESMRResponseObserver* aResponseObserver,
       
   160         TBool aResponseReady,
       
   161         const TInt &aReqAttendee,
       
   162         const TInt &aOptAttendee)
       
   163     {
       
   164     FUNC_LOG;
       
   165     CESMRField* field = NULL;
       
   166     RArray<TESMREntryField> fields = aPolicy.Fields();
       
   167 
       
   168     if (aReqAttendee > 0)
       
   169         {
       
   170         //create "required attendee" label
       
   171         field = CreateViewerFieldL( 
       
   172 					aResponseObserver, 
       
   173 					fields[KRequiredLabel], 
       
   174 					aResponseReady);
       
   175         CleanupStack::PushL( field );
       
   176         AddFieldL( field );
       
   177         CleanupStack::Pop( field );
       
   178 
       
   179         //create attendee status
       
   180         for ( TInt j(0); j < aReqAttendee ; j++ )
       
   181              {
       
   182              field = CreateViewerFieldL( 
       
   183 						 aResponseObserver, 
       
   184 						 fields[KStatusField], 
       
   185 						 aResponseReady);
       
   186              CleanupStack::PushL( field );
       
   187              AddFieldL( field );
       
   188              CleanupStack::Pop( field );
       
   189              }
       
   190         }
       
   191 
       
   192     if (aOptAttendee > 0)
       
   193         {
       
   194         //create "optional attendee" label
       
   195         field = CreateViewerFieldL( 
       
   196 					aResponseObserver, 
       
   197 					fields[KOptionalLabel], 
       
   198 					aResponseReady);
       
   199         CleanupStack::PushL( field );
       
   200         AddFieldL( field );
       
   201         CleanupStack::Pop( field );
       
   202 
       
   203         //create attendee status
       
   204         for ( TInt j(0); j < aOptAttendee ; j++ )
       
   205              {
       
   206              field = CreateViewerFieldL( 
       
   207 						 aResponseObserver, 
       
   208 						 fields[KStatusField], 
       
   209 						 aResponseReady);
       
   210              CleanupStack::PushL( field );
       
   211              AddFieldL( field );
       
   212              CleanupStack::Pop( field );
       
   213              }
       
   214         }
       
   215 
       
   216     //this dummy field is created as a fallback because 
       
   217     //empty screen with no fields will crash with any key input.
       
   218     if(!aOptAttendee && !aReqAttendee )
       
   219         {
       
   220         field = CreateViewerFieldL( 
       
   221 					aResponseObserver, 
       
   222 					fields[KRequiredLabel], 
       
   223 					aResponseReady);
       
   224         CleanupStack::PushL( field );
       
   225         AddFieldL( field );
       
   226         CleanupStack::Pop( field );
       
   227         }
       
   228     }
       
   229 
       
   230 
       
   231 // EOF
       
   232