meetingrequest/mrgui/src/cesmrviewerfieldstorage.cpp
changeset 0 8466d47a6819
child 12 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 : Storage for viewer fields
       
    15 *  Version     : %version: tr1sido#6 %
       
    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         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         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(CESMRPolicy* aPolicy,
       
   131         MESMRResponseObserver* aResponseObserver,
       
   132         TBool aResponseReady)
       
   133     {
       
   134     FUNC_LOG;
       
   135     CESMRField* field = NULL;
       
   136     
       
   137     RArray<TESMREntryField> fields = aPolicy->Fields();
       
   138     const TInt count = fields.Count();
       
   139     for ( TInt i(0); i < count ; i++ )
       
   140         {
       
   141         field = CreateViewerFieldL( 
       
   142         		aResponseObserver, fields[i], aResponseReady );
       
   143 
       
   144         TBool visible( ETrue );
       
   145             
       
   146         switch ( fields[i].iFieldId )
       
   147             {
       
   148             case EESMRFieldResponseArea:
       
   149                 {
       
   150                 if ( aResponseReady )
       
   151                     {
       
   152                     visible = EFalse;
       
   153                     }
       
   154                 break;
       
   155                 }
       
   156             case EESMRFieldResponseReadyArea:
       
   157                 {
       
   158                 if ( !aResponseReady )
       
   159                     {
       
   160                     visible = EFalse;
       
   161                     }
       
   162                 break;
       
   163                 }
       
   164             default:
       
   165                 {
       
   166                 break;
       
   167                 }
       
   168             }
       
   169         
       
   170         CleanupStack::PushL( field );
       
   171         AddFieldL( field, visible );
       
   172         CleanupStack::Pop( field );
       
   173         }
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CESMRViewerFieldStorage::CreateTrackingFieldsL
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 void CESMRViewerFieldStorage::CreateTrackingFieldsL(CESMRPolicy* aPolicy,
       
   181         MESMRResponseObserver* aResponseObserver,
       
   182         TBool aResponseReady,
       
   183         const TInt &aReqAttendee,
       
   184         const TInt &aOptAttendee)
       
   185     {
       
   186     FUNC_LOG;
       
   187     CESMRField* field = NULL;
       
   188     RArray<TESMREntryField> fields = aPolicy->Fields();
       
   189 
       
   190     if (aReqAttendee > 0)
       
   191         {
       
   192         //create "required attendee" label
       
   193         field = CreateViewerFieldL( 
       
   194 					aResponseObserver, 
       
   195 					fields[KRequiredLabel], 
       
   196 					aResponseReady);
       
   197         CleanupStack::PushL( field );
       
   198         AddFieldL( field );
       
   199         CleanupStack::Pop( field );
       
   200 
       
   201         //create attendee status
       
   202         for ( TInt j(0); j < aReqAttendee ; j++ )
       
   203              {
       
   204              field = CreateViewerFieldL( 
       
   205 						 aResponseObserver, 
       
   206 						 fields[KStatusField], 
       
   207 						 aResponseReady);
       
   208              CleanupStack::PushL( field );
       
   209              AddFieldL( field );
       
   210              CleanupStack::Pop( field );
       
   211              }
       
   212         }
       
   213 
       
   214     if (aOptAttendee > 0)
       
   215         {
       
   216         //create "optional attendee" label
       
   217         field = CreateViewerFieldL( 
       
   218 					aResponseObserver, 
       
   219 					fields[KOptionalLabel], 
       
   220 					aResponseReady);
       
   221         CleanupStack::PushL( field );
       
   222         AddFieldL( field );
       
   223         CleanupStack::Pop( field );
       
   224 
       
   225         //create attendee status
       
   226         for ( TInt j(0); j < aOptAttendee ; j++ )
       
   227              {
       
   228              field = CreateViewerFieldL( 
       
   229 						 aResponseObserver, 
       
   230 						 fields[KStatusField], 
       
   231 						 aResponseReady);
       
   232              CleanupStack::PushL( field );
       
   233              AddFieldL( field );
       
   234              CleanupStack::Pop( field );
       
   235              }
       
   236         }
       
   237 
       
   238     //this dummy field is created as a fallback because 
       
   239     //empty screen with no fields will crash with any key input.
       
   240     if(!aOptAttendee && !aReqAttendee )
       
   241         {
       
   242         field = CreateViewerFieldL( 
       
   243 					aResponseObserver, 
       
   244 					fields[KRequiredLabel], 
       
   245 					aResponseReady);
       
   246         CleanupStack::PushL( field );
       
   247         AddFieldL( field );
       
   248         CleanupStack::Pop( field );
       
   249         }
       
   250     }
       
   251 
       
   252 
       
   253 // EOF
       
   254