meetingrequest/mrgui/src/cesmrfieldstorage.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:  ESMR UI Factory implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cesmrfieldstorage.h"
       
    19 #include "cesmrfield.h"
       
    20 #include "mesmrcalentry.h"
       
    21 #include "cesmrfieldeventqueue.h"
       
    22 #include "cmrsystemnotifier.h"
       
    23 
       
    24 #include <touchfeedback.h>
       
    25 
       
    26 #include "emailtrace.h"
       
    27 
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CESMRFieldStorage::CESMRFieldStorage()
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CESMRFieldStorage::CESMRFieldStorage(
       
    36 		MESMRFieldEventObserver& aEventObserver ):
       
    37 	iEventObserver( aEventObserver )
       
    38     {
       
    39     FUNC_LOG;
       
    40     // Do nothing
       
    41     }
       
    42 
       
    43 void CESMRFieldStorage::BaseConstructL()
       
    44     {
       
    45     FUNC_LOG;
       
    46     // Add event observer to event queue
       
    47     EventQueueL().AddObserverL( &iEventObserver );    
       
    48     iSystemNotifier = CMRSystemNotifier::NewL( EventQueueL() );
       
    49     iSystemNotifier->StartL();
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CESMRFieldStorage::~CESMRFieldStorage()
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CESMRFieldStorage::~CESMRFieldStorage()
       
    57     {
       
    58     FUNC_LOG;
       
    59     iArray.ResetAndDestroy();
       
    60 
       
    61     delete iPlugin;
       
    62     delete iSystemNotifier;
       
    63     delete iEventQueue;    
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CESMRFieldStorage::AddFieldL()
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CESMRFieldStorage::AddFieldL( CESMRField* aField )
       
    71     {
       
    72     FUNC_LOG;
       
    73     if ( aField )
       
    74         {
       
    75         AddFieldL( aField, ETrue );
       
    76         }
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CESMRFieldStorage::AddFieldL()
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void CESMRFieldStorage::AddFieldL( CESMRField* aField, TBool aVisible )
       
    84     {
       
    85     FUNC_LOG;
       
    86     if ( aField )
       
    87         {
       
    88         iArray.ReserveL( iArray.Count() + 1 );
       
    89         aField->SetEventQueueL( iEventQueue );
       
    90         aField->MakeVisible( aVisible );
       
    91         iArray.AppendL( aField );
       
    92         }
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CESMRFieldStorage::Count()
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 TInt CESMRFieldStorage::Count() const
       
   100     {
       
   101     FUNC_LOG;
       
   102     return iArray.Count();
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CESMRFieldStorage::Field()
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 CESMRField* CESMRFieldStorage::Field( TInt aInd ) const
       
   110     {
       
   111     FUNC_LOG;
       
   112     return iArray[ aInd ];
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CESMRFieldStorage::FieldById
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 CESMRField* CESMRFieldStorage::FieldById( TESMREntryFieldId aId ) const
       
   120     {
       
   121     CESMRField* field = NULL;
       
   122 
       
   123     for ( TInt i = 0; i < iArray.Count(); ++i )
       
   124         {
       
   125         if ( iArray[ i ]->FieldId() == aId )
       
   126             {
       
   127             field = iArray[ i ];
       
   128             break;
       
   129             }
       
   130         }
       
   131 
       
   132     return field;
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CESMRFieldStorage::Validate()
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 TInt CESMRFieldStorage::Validate(
       
   140 		TESMREntryFieldId& /*aId */,
       
   141 		TBool /*aForceValidation*/ )
       
   142     {
       
   143     FUNC_LOG;
       
   144     return KErrNone;
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CESMRFieldStorage::InternalizeL()
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CESMRFieldStorage::InternalizeL( MESMRCalEntry& aEntry )
       
   152     {
       
   153     FUNC_LOG;
       
   154 
       
   155     TInt index(0);
       
   156     while( index < iArray.Count() )
       
   157         {
       
   158         TInt fieldCount( iArray.Count() );
       
   159         iArray[ index ]->InternalizeL( aEntry );
       
   160 
       
   161         if ( fieldCount == iArray.Count() )
       
   162             {
       
   163             // Field that was internalized was not removed from list
       
   164             // We can update field index. If field is removed the next
       
   165             // field index is already the current index ...
       
   166             index++;
       
   167             }
       
   168         }
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CESMRFieldStorage::ExternalizeL()
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 void CESMRFieldStorage::ExternalizeL( MESMRCalEntry& aEntry )
       
   176     {
       
   177     FUNC_LOG;
       
   178     for ( TInt i(0); i < iArray.Count(); i++ )
       
   179         {
       
   180         if(iArray[ i ]->IsVisible())
       
   181         	{
       
   182         	iArray[ i ]->ExternalizeL( aEntry );
       
   183         	}
       
   184         }
       
   185     }
       
   186 
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CESMRFieldStorage::FieldBuilderL()
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 MESMRFieldBuilder* CESMRFieldStorage::FieldBuilderL()
       
   193     {
       
   194     FUNC_LOG;
       
   195     if(!iFieldBuilder)
       
   196         {
       
   197         LoadPluginL();
       
   198         }
       
   199     return iFieldBuilder;
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CESMRFieldStorage::LoadPluginL()
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CESMRFieldStorage::LoadPluginL()
       
   207     {
       
   208     FUNC_LOG;
       
   209     iFieldBuilder = NULL;
       
   210     CESMRFieldBuilderInterface* plugin = NULL;
       
   211 
       
   212 	TRAPD( error, plugin =
       
   213 		CESMRFieldBuilderInterface::CreatePluginL(
       
   214 				TUid::Uid(KESMRUIFieldBuilderPluginImplUId) ) );
       
   215 
       
   216 	if ( error == KErrNone && plugin)
       
   217 		{
       
   218 		delete iPlugin;
       
   219 		iPlugin = plugin;
       
   220 
       
   221 		iFieldBuilder = iPlugin->FieldBuilderL();
       
   222 		}
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CESMRFieldStorage::CreateEditorFieldL()
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 CESMRField* CESMRFieldStorage::CreateEditorFieldL(
       
   230 		MESMRFieldValidator* aValidator,
       
   231 		TESMREntryField aField )
       
   232     {
       
   233     FUNC_LOG;
       
   234     CESMRField* field = NULL;
       
   235 
       
   236     if (FieldBuilderL())
       
   237         {
       
   238         field = FieldBuilderL()->CreateEditorFieldL(aValidator, aField);
       
   239         }
       
   240 
       
   241     return field;
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CESMRFieldStorage::CreateViewerFieldL()
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 CESMRField* CESMRFieldStorage::CreateViewerFieldL(
       
   249 		MESMRResponseObserver* aResponseObserver,
       
   250 		TESMREntryField aField,
       
   251 		TBool aResponseReady )
       
   252     {
       
   253     FUNC_LOG;
       
   254     CESMRField* field = NULL;
       
   255 
       
   256     if (FieldBuilderL())
       
   257         {
       
   258         field = FieldBuilderL()->CreateViewerFieldL(
       
   259 					aResponseObserver, aField, aResponseReady );
       
   260         }
       
   261     return field;
       
   262     }
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CESMRFieldStorage::ChangePolicyL()
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 void CESMRFieldStorage::ChangePolicyL(
       
   269         const CESMRPolicy& /*aNewPolicy*/,
       
   270         MESMRCalEntry& /*aEntry*/ )
       
   271     {
       
   272     ASSERT( EFalse ); // Assert for debug builds
       
   273     User::Leave( KErrNotSupported );
       
   274     }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CESMRFieldStorage::EventQueueL()
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 CESMRFieldEventQueue& CESMRFieldStorage::EventQueueL()
       
   281     {
       
   282     FUNC_LOG;
       
   283     if ( !iEventQueue )
       
   284         {
       
   285         iEventQueue = CESMRFieldEventQueue::NewL();
       
   286         }
       
   287     return *iEventQueue;
       
   288     }
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // CESMRFieldStorage::RemoveField()
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 void CESMRFieldStorage::RemoveField( TInt aInd )
       
   295     {
       
   296     CESMRField* field = iArray[ aInd ];
       
   297     iArray.Remove( aInd );
       
   298     delete field;
       
   299     }
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CESMRFieldStorage::InsertFieldL()
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 void CESMRFieldStorage::InsertFieldL( CESMRField* aField, TInt aIndex )
       
   306     {
       
   307     iArray.InsertL( aField, aIndex );
       
   308     aField->SetEventQueueL( iEventQueue );
       
   309     }
       
   310 
       
   311 // -----------------------------------------------------------------------------
       
   312 // CESMRFieldStorage::ReserveL()
       
   313 // -----------------------------------------------------------------------------
       
   314 //
       
   315 void CESMRFieldStorage::ReserveL( TInt aCount )
       
   316     {
       
   317     iArray.ReserveL( aCount );
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CESMRFieldStorage::Reset()
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CESMRFieldStorage::Reset()
       
   325     {
       
   326     iArray.ResetAndDestroy();
       
   327     }
       
   328 // EOF
       
   329