calendarui/organizerplugin/aiagendaplugin2/src/aicalendarplugin2.cpp
changeset 0 f979ecb2b13e
child 5 42814f902fe6
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  
       
    15  *
       
    16 */
       
    17 
       
    18 #include "aicalendarplugin2.h"
       
    19 #include "aicalendarplugin2contentmodel.h"
       
    20 #include "AIAgendaPluginEngineIf.h"
       
    21 #include "aicalendarplugin2constantdata.h"
       
    22 #include "aicalendarplugin2data.h"
       
    23 #include "aicalendarplugin2constants.hrh"
       
    24 #include "aicalendarplugin2uids.hrh"
       
    25 
       
    26 #include <aicalendarplugin2.mbg>
       
    27 #include <calendar.mbg>
       
    28 #include <gulicon.h>
       
    29 #include <bautils.h>
       
    30 #include <ecom/implementationproxy.h>
       
    31 
       
    32 #include <aistrparser.h>
       
    33 #include <aiutility.h>
       
    34 #include <aipluginsettings.h>
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 const TInt KAI2CurrentIconLoadSizeX = 40;
       
    39 const TInt KAI2CurrentIconLoadSizeY = 40;
       
    40 
       
    41 const TInt KAI2InternalIdForNoEvents = -357;
       
    42 const TInt KAI2InternalIdForNoMoreEvents = -38;
       
    43 const TInt KAI2InternalIdForNextEvent = -44;
       
    44 const TInt KAI2InternalIdForNextEvents = -45;
       
    45 const TInt KAI2InternalIdForNextEventTomorrow = -762;
       
    46 
       
    47 enum TAi2CalIcons
       
    48     {
       
    49     // Lets be explicit to maintain readability
       
    50     KAi2IconCalendar = 0,
       
    51     KAi2MeetingIcon, // 1
       
    52     KAi2Memo, // 2
       
    53     KAi2Anniversary, // 3
       
    54     KAi2UncompeledTodo // 4
       
    55     };
       
    56 
       
    57 _LIT( KResourceDrive, "z:" );
       
    58 _LIT( KCalendarBitmapFile, "calendar.mif" );
       
    59 _LIT( KAIPluginIconBitmapFile, "aicalendarplugin2.mif" );
       
    60 _LIT( KCalendarResourceFile, "calendar.rsc" );
       
    61 _LIT( KAIPluginTextsResourceFileName,    "aicalendarplugin2res.rsc");
       
    62 
       
    63 _LIT16( KHexPrefix16, "0x" );
       
    64 
       
    65 
       
    66 TInt ParseInt
       
    67         ( TInt32& aValue, const TDesC16& aStringValue )
       
    68     {
       
    69     const TInt pos = aStringValue.FindF( KHexPrefix16 );
       
    70     if (pos != KErrNotFound)
       
    71         {
       
    72         TLex16 lex( aStringValue.Mid( pos + KHexPrefix16().Length() ) );
       
    73         // Hex parsing needs unsigned int
       
    74         TUint32 value = 0;
       
    75         const TInt parseResult = lex.Val( value, EHex );
       
    76         if ( parseResult == KErrNone )
       
    77             {
       
    78             aValue = value;
       
    79             }
       
    80         return parseResult;
       
    81         }
       
    82     else
       
    83         {
       
    84         TLex16 lex( aStringValue );
       
    85         return lex.Val(aValue);
       
    86         }
       
    87     }
       
    88     
       
    89 TInt GetTimedItemLineNeed(
       
    90                 RPointerArray<CAiCalendarPlugin2EventItem>& /*aArray*/,
       
    91                 TInt /*aArrayOffset*/ )
       
    92     {
       
    93     // Multiline cale
       
    94     return 1;
       
    95     }
       
    96 
       
    97 TInt GetTimedArrayLineNeed(
       
    98                 RPointerArray<CAiCalendarPlugin2EventItem>& aArray, TInt aSpaceTaken )
       
    99     {
       
   100     // Multiline cale
       
   101     return aArray.Count() * aSpaceTaken;
       
   102     }
       
   103 
       
   104 TInt CalculateStartIndexBackwards(
       
   105                 RPointerArray<CAiCalendarPlugin2EventItem>& aArray,
       
   106                 TInt aLinesAvailable,
       
   107                 TInt spaceUse,
       
   108                 TBool aHasPriority )
       
   109     {
       
   110     TInt i = aArray.Count() - 1;
       
   111     TInt totalSpace = 0;
       
   112     for( ; i >= 0; --i )
       
   113         {
       
   114         if( totalSpace + spaceUse >= aLinesAvailable )
       
   115             {
       
   116             if( totalSpace + spaceUse > aLinesAvailable )
       
   117                 {
       
   118                 ++i;
       
   119                 }
       
   120             break;
       
   121             }
       
   122         totalSpace += spaceUse;
       
   123         }
       
   124     if( i >= aArray.Count() )
       
   125         {
       
   126         i = aArray.Count() - 1;
       
   127         }
       
   128     else if( ( ( i < 0 ) && aHasPriority ) ||// <- if there is little space left only priority item are
       
   129                                         //    fitted to the screen
       
   130         ( aLinesAvailable > aArray.Count() ) )// <- if theres lot of space, make sure to fit us too
       
   131         {
       
   132         i = 0;
       
   133         }
       
   134     return i;
       
   135     }
       
   136 
       
   137 // Provide a key pair value table for ECOM.
       
   138 // Used to identify the correct construction function for the requested interface.
       
   139 const TImplementationProxy ImplementationTable[] = 
       
   140     {
       
   141     IMPLEMENTATION_PROXY_ENTRY( AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_CALENDARPLUGIN,
       
   142                                 CAICalendarPlugin2::NewL )
       
   143     };
       
   144 
       
   145 // ============================ MEMBER FUNCTIONS ===============================
       
   146 
       
   147 CAICalendarPlugin2* CAICalendarPlugin2::NewL()
       
   148     {
       
   149     CAICalendarPlugin2* self = new( ELeave )CAICalendarPlugin2;
       
   150     CleanupStack::PushL( self );
       
   151     self->ConstructL();
       
   152     CleanupStack::Pop( self );
       
   153     return self;
       
   154     }
       
   155 
       
   156 CAICalendarPlugin2::CAICalendarPlugin2()
       
   157   : iActualLinesInUse( KAICal2DefaultActualLines ),
       
   158     iNonTimedItemReservation( KAICal2DefaultItemReservation )
       
   159     {
       
   160     }
       
   161 
       
   162 void CAICalendarPlugin2::ConstructL()
       
   163     {
       
   164     if( !iCalendarResourceFileOffset )
       
   165         {
       
   166         TFileName resFile;
       
   167         resFile.Append( KResourceDrive );
       
   168         resFile.Append( KDC_APP_RESOURCE_DIR );
       
   169         resFile.Append( KCalendarResourceFile );
       
   170         BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );
       
   171         iCalendarResourceFileOffset = CCoeEnv::Static()->AddResourceFileL( resFile );
       
   172         }
       
   173         
       
   174     if( !iTextResourceFileOffset )
       
   175         {
       
   176         TFileName resFile;
       
   177         resFile.Append( KResourceDrive );
       
   178         resFile.Append( KDC_RESOURCE_FILES_DIR );
       
   179         resFile.Append( KAIPluginTextsResourceFileName );
       
   180         BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );
       
   181         iTextResourceFileOffset = CCoeEnv::Static()->AddResourceFileL( resFile );
       
   182         }
       
   183         
       
   184     iCalendarIconFileName = HBufC::NewL( KResourceDrive().Length() +
       
   185                                          KDC_APP_BITMAP_DIR().Length() +
       
   186                                          KCalendarBitmapFile().Length() );
       
   187     iCalendarIconFileName->Des().Append( KResourceDrive );
       
   188     iCalendarIconFileName->Des().Append( KDC_APP_BITMAP_DIR );
       
   189     iCalendarIconFileName->Des().Append( KCalendarBitmapFile );
       
   190 
       
   191     iPluginIconFileName = HBufC::NewL( KResourceDrive().Length() +
       
   192                                        KDC_APP_BITMAP_DIR().Length() +
       
   193                                        KAIPluginIconBitmapFile().Length() );
       
   194     iPluginIconFileName->Des().Append( KResourceDrive );
       
   195     iPluginIconFileName->Des().Append( KDC_APP_BITMAP_DIR );
       
   196     iPluginIconFileName->Des().Append( KAIPluginIconBitmapFile );
       
   197 
       
   198     iConstantData = CAICalendarPlugin2ConstantData::NewL();
       
   199     iEventData = CAICalendarPlugin2Data::NewL();
       
   200     iStrParser = AiUtility::CreateStrParserL();
       
   201     }
       
   202 
       
   203 CAICalendarPlugin2::~CAICalendarPlugin2()
       
   204     {
       
   205     if( iCalendarResourceFileOffset )
       
   206         {
       
   207         CCoeEnv::Static()->DeleteResourceFile( iCalendarResourceFileOffset );
       
   208         }
       
   209     if( iTextResourceFileOffset )
       
   210         {
       
   211         CCoeEnv::Static()->DeleteResourceFile( iTextResourceFileOffset );
       
   212         }
       
   213     delete iEngine;
       
   214     delete iEventData;
       
   215     delete iConstantData;
       
   216     Release( iStrParser );
       
   217         
       
   218     iBitmaps.ResetAndDestroy();
       
   219     iMasks.ResetAndDestroy();
       
   220     
       
   221     delete iPluginIconFileName;
       
   222     delete iCalendarIconFileName;
       
   223     iPublishedDataStore.Reset();
       
   224     iNewCollectedDataStore.Reset();
       
   225 	delete iPrevUid;
       
   226     }
       
   227     
       
   228 void CAICalendarPlugin2::CreateBitmapSkinnedIconL( const TAknsItemID& aSkinIconId,
       
   229                                                    const TDesC& aFilename,
       
   230                                                    TInt aNormalIconId,
       
   231                                                    TInt aNormalMaskId,
       
   232                                                    CFbsBitmap*& aBitmap,
       
   233                                                    CFbsBitmap*& aMask )
       
   234     {
       
   235     AknsUtils::CreateIconLC( AknsUtils::SkinInstance(), 
       
   236                              aSkinIconId, 
       
   237                              aBitmap, 
       
   238                              aMask, 
       
   239                              aFilename, 
       
   240                              aNormalIconId, 
       
   241                              aNormalMaskId );
       
   242 
       
   243     CleanupStack::Pop( 2 );  // bitmap, mask, cant use pop param here, we dont know
       
   244                              // the push order of the CreateIconLC
       
   245     }
       
   246 
       
   247 void CAICalendarPlugin2::CreateIconsL(void)
       
   248     {
       
   249     CFbsBitmap* bitmap;
       
   250     CFbsBitmap* mask;
       
   251     iBitmaps.ResetAndDestroy();
       
   252     iMasks.ResetAndDestroy();
       
   253 
       
   254     TSize iconSize( TSize( KAI2CurrentIconLoadSizeX,
       
   255                            KAI2CurrentIconLoadSizeY ) );
       
   256     /**
       
   257      * Creation order!:
       
   258      *   Calendar icon
       
   259      *   Meeting icon
       
   260      *   Note icon
       
   261      *   Anniversary icon
       
   262      *   Uncompleted to-do icon
       
   263      *   
       
   264      **/
       
   265     CreateBitmapSkinnedIconL( KAknsIIDQgnIndiAiCale, 
       
   266                               *iPluginIconFileName, 
       
   267                               EMbmAicalendarplugin2Qgn_indi_ai_cale, 
       
   268                               EMbmAicalendarplugin2Qgn_indi_ai_cale_mask,
       
   269                               bitmap, mask );
       
   270 
       
   271     // These bitmaps are permanently owned by arrays here.
       
   272     // Only duplicates are provided to system, are they can
       
   273     // do whatever they want to them.
       
   274     User::LeaveIfError( iBitmaps.Append( bitmap ) );
       
   275     User::LeaveIfError( iMasks.Append( mask ) );
       
   276     User::LeaveIfError( 
       
   277         AknIconUtils::SetSize( bitmap, iconSize ) );
       
   278 
       
   279     CreateBitmapSkinnedIconL( KAknsIIDQgnIndiCdrMeeting, 
       
   280                               *iCalendarIconFileName, 
       
   281                               EMbmCalendarQgn_indi_cdr_meeting, 
       
   282                               EMbmCalendarQgn_indi_cdr_meeting_mask,
       
   283                               bitmap, mask );
       
   284     User::LeaveIfError( iBitmaps.Append( bitmap ) );
       
   285     User::LeaveIfError( iMasks.Append( mask ) );
       
   286     User::LeaveIfError( 
       
   287         AknIconUtils::SetSize( bitmap, iconSize ) );
       
   288 
       
   289     CreateBitmapSkinnedIconL( KAknsIIDQgnIndiCdrReminder, 
       
   290                               *iCalendarIconFileName, 
       
   291                               EMbmCalendarQgn_indi_cdr_reminder, 
       
   292                               EMbmCalendarQgn_indi_cdr_reminder_mask,
       
   293                               bitmap, mask );
       
   294     User::LeaveIfError( iBitmaps.Append( bitmap ) );
       
   295     User::LeaveIfError( iMasks.Append( mask ) );
       
   296     User::LeaveIfError( 
       
   297         AknIconUtils::SetSize( bitmap, iconSize ) );
       
   298 
       
   299     CreateBitmapSkinnedIconL( KAknsIIDQgnIndiCdrBirthday, 
       
   300                               *iCalendarIconFileName, 
       
   301                               EMbmCalendarQgn_indi_cdr_birthday, 
       
   302                               EMbmCalendarQgn_indi_cdr_birthday_mask,
       
   303                               bitmap, mask );
       
   304     User::LeaveIfError( iBitmaps.Append( bitmap ) );
       
   305     User::LeaveIfError( iMasks.Append( mask ) );
       
   306     User::LeaveIfError( 
       
   307         AknIconUtils::SetSize( bitmap, iconSize ) );
       
   308     
       
   309     CreateBitmapSkinnedIconL( KAknsIIDQgnPropTodoUndone, 
       
   310                               *iCalendarIconFileName, 
       
   311                               EMbmCalendarQgn_indi_cdr_todo, 
       
   312                               EMbmCalendarQgn_indi_cdr_todo_mask,
       
   313                               bitmap, mask );
       
   314     User::LeaveIfError( iBitmaps.Append( bitmap ) );
       
   315     User::LeaveIfError( iMasks.Append( mask ) );
       
   316     User::LeaveIfError( 
       
   317         AknIconUtils::SetSize( bitmap, iconSize ) );
       
   318                                      
       
   319     iBitmaps.Compress();
       
   320     iMasks.Compress();
       
   321     }    
       
   322 
       
   323 void CAICalendarPlugin2::Resume( TAiTransitionReason aReason )
       
   324     {
       
   325     TRAP_IGNORE( DoResumeL( aReason ) );
       
   326     }
       
   327 
       
   328 void CAICalendarPlugin2::DoResumeL( TAiTransitionReason aReason )
       
   329     {
       
   330     if( aReason == EAiIdleForeground ||
       
   331         aReason == EAiBacklightOn ||
       
   332         aReason == EAiSystemStartup ||
       
   333         aReason == EAiGeneralThemeChanged )
       
   334         {
       
   335         if( aReason == EAiGeneralThemeChanged )
       
   336             {
       
   337             // Reset for republishing. Especially icons!
       
   338             iPublishedDataStore.Reset();
       
   339             }
       
   340         if( !iEngine )
       
   341             {
       
   342             iEngine = CAIAgendaPluginEngineIf::NewL( *this, ECalendarAndTodoObserver );
       
   343             }
       
   344         else
       
   345             {
       
   346             iEngine->Refresh();
       
   347             }
       
   348         }
       
   349     }
       
   350 
       
   351 void CAICalendarPlugin2::Suspend( TAiTransitionReason /*aReason*/ )
       
   352     {
       
   353     delete iEngine;
       
   354     iEngine = NULL;
       
   355     }
       
   356 
       
   357 void CAICalendarPlugin2::Stop( TAiTransitionReason /*aReason*/ )
       
   358     {
       
   359     delete iEngine;
       
   360     iEngine = NULL;
       
   361     iPublishedDataStore.Reset();
       
   362     }
       
   363 
       
   364 void CAICalendarPlugin2::SubscribeL( MAiContentObserver& aObserver )
       
   365     {
       
   366     iEventData->AppendObserverL( aObserver );
       
   367     }
       
   368 
       
   369 void CAICalendarPlugin2::ConfigureL( RAiSettingsItemArray& aSettings )
       
   370     {
       
   371     // Receive the settings for this plugin from the user(theme or similar).
       
   372     // There are four settings we need for the current implementation to work
       
   373     // properly:
       
   374     //
       
   375     // 1) total item count of the UI = EPluginEventItemCount
       
   376     //
       
   377     // 2) the vertical space taken by timed item (relative to the size of non timed item)
       
   378     //    = EPluginTimedEventLineCount
       
   379     //
       
   380     // 3) the vertical space taken by non timed item (relative to the size of timed item)
       
   381     //    = EPluginNonTimedEventLineCount
       
   382     //
       
   383     // 4) the amount of lines we reserve for non timed events if many timed and non timed
       
   384     //    events are present = EPluginNonTimedReservedItems
       
   385     //
       
   386     // In the current 2.6.2006 specification for example (Navibar theme), we have non timed items
       
   387     // half the vertical size of timed items. Timed items take 2 lines visible space and
       
   388     // non timed take 1 line of visible space. We need to able to show at maximum 6
       
   389     // non timed items, so we need total 6 items (1 line items). As timed items take
       
   390     // 2 lines we can fit three of them in to the view (no setting need/can be calculated)
       
   391     // as stated in the specification. If many timed and non timed calendar events are 
       
   392     // present we always reserve 2 times for non timed events.
       
   393     // So the setting to satisfy the UI spec of the "Navibar UI" are 6, 2, 1, 2
       
   394     //
       
   395     //
       
   396     for( TInt i = 0; i < aSettings.Count(); ++i )
       
   397         {
       
   398         MAiPluginSettingsItem& item = (aSettings[i])->AiPluginSettingsItem();
       
   399         TInt32 value = 0;
       
   400         if( ParseInt( value, item.Value() ) != KErrNone )
       
   401             {
       
   402             continue;
       
   403             }
       
   404         if( value < 0 )
       
   405             {
       
   406             continue;
       
   407             }
       
   408 
       
   409         if( item.Key() == EPluginEventItemCount )
       
   410             {
       
   411             iActualLinesInUse = value;
       
   412             continue;
       
   413             }
       
   414         else if( item.Key() == EPluginTimedEventLineCount )
       
   415             {
       
   416             iEventData->SetSpaceTakenByTimedEvent( value );
       
   417             continue;
       
   418             }
       
   419         else if( item.Key() == EPluginNonTimedEventLineCount )
       
   420             {
       
   421             iEventData->SetSpaceTakenByNonTimedEvent( value );
       
   422             continue;
       
   423             }
       
   424         else if( item.Key() == EPluginNonTimedReservedItems )
       
   425             {
       
   426             iNonTimedItemReservation = value;
       
   427             continue;
       
   428             }
       
   429         else if( item.Key() == EPluginAppendEndTimeToOngoingItems )
       
   430             {
       
   431             iConstantData->iAppendEndTimeToOngoingItems = value;
       
   432             continue;
       
   433             }
       
   434         else if( item.Key() == EPluginUseAlternatePublishForUpcomingAndOngoingItems )
       
   435             {
       
   436             iConstantData->iUseAlternatePublish = value;
       
   437             continue;
       
   438             }
       
   439         else if( item.Key() == EPluginOpenInViewerOrEditor )
       
   440             {
       
   441             iConstantData->iOpenInViewer = !value;
       
   442             continue;
       
   443             }
       
   444         else if( item.Key() == EPluginDaysToHandleAsNotToday )
       
   445             {
       
   446             iConstantData->iDaysToHandleAsNotToday = value;
       
   447             continue;
       
   448             }
       
   449         else if( item.Key() == EPluginOpenFirstValidOnIndexZero )
       
   450             {
       
   451             iConstantData->iOpenFirstValid = value;
       
   452             continue;
       
   453             }
       
   454         else if ( item.Key() == EPluginPublishInfoWithAlternateId )
       
   455             {
       
   456             iConstantData->iUseAlternateInfoPublish = value;
       
   457             continue;
       
   458             }
       
   459         
       
   460         }
       
   461     // Last op, free array and items
       
   462     aSettings.ResetAndDestroy();
       
   463     }
       
   464 
       
   465 TAny* CAICalendarPlugin2::Extension( TUid aUid )
       
   466     {
       
   467     if (aUid == KExtensionUidProperty)
       
   468         {
       
   469         return static_cast<MAiPropertyExtension*>(this);
       
   470         }
       
   471     else if (aUid == KExtensionUidEventHandler)
       
   472         {
       
   473         return static_cast<MAiEventHandlerExtension*>(this);
       
   474         }
       
   475     return NULL;
       
   476     }
       
   477 
       
   478 TAny* CAICalendarPlugin2::GetPropertyL( TInt aProperty )
       
   479     {
       
   480     return iConstantData->GetPropertyL( aProperty );
       
   481     }
       
   482 
       
   483 void CAICalendarPlugin2::SetPropertyL( TInt aProperty, TAny* aValue )
       
   484     {
       
   485     if( aValue )
       
   486         {
       
   487         iConstantData->SetPropertyL( aProperty, aValue );
       
   488         }
       
   489     }
       
   490 
       
   491 void CAICalendarPlugin2::HandleEvent( TInt aEvent, const TDesC& aParam )
       
   492     {
       
   493     if( aEvent == EAICalendarPlugin2EventItemSelected )
       
   494         {
       
   495         TInt32 index = 0;
       
   496         if( ParseInt( index, aParam ) != KErrNone )
       
   497             {
       
   498             return;
       
   499             }
       
   500             
       
   501         // Other "out of bounds" checked inside launch method.
       
   502         if( index > iActualLinesInUse )
       
   503             {
       
   504             // invalid index
       
   505             return;
       
   506             }
       
   507         iEventData->LaunchCalendarApplication( index, iConstantData->iOpenFirstValid );
       
   508         }
       
   509     }
       
   510 
       
   511 void CAICalendarPlugin2::PluginDataChanged(
       
   512                     const RPointerArray<CCalInstance>& aEntryArray,
       
   513                     TBool aHadEvents )
       
   514     {
       
   515     iEventData->SetHadExpiredEvents( aHadEvents );
       
   516 
       
   517     iEventData->ClearDataArrays();
       
   518 
       
   519     TRAP_IGNORE(
       
   520         FillDataArraysL( aEntryArray );
       
   521         PublishDataArraysL();
       
   522         );
       
   523     }
       
   524 
       
   525 void CAICalendarPlugin2::FillDataArraysL(
       
   526                     const RPointerArray<CCalInstance>& aEntryArray )
       
   527     {
       
   528     /**
       
   529      * [uses icon y/n] time formatting | subject and location formatting
       
   530      *
       
   531      * [Y] 13:05-14:00 subject, location...  // normal day event
       
   532      * [Y] 00:00-08:00 subject, location...  // event starting yesterday
       
   533      * [Y] 19:00-23:59 subject, location...  // event ends tomorrow
       
   534      * [Y] 16:50-16:50 subject, location...  // event with no duration
       
   535      * [Y] 25/8/04 16:00- subject...  // normal not today event
       
   536      * [Y] subject...  // normal non timed event
       
   537      * [Y] 25/8/04 subject...  // not today non timed event
       
   538      * 26.10.2006 Tuomas Karjagin: - all item now will use icons
       
   539      *                             - end time removed from normal not today.
       
   540      **/
       
   541 
       
   542     // extract new data from CAgnEntry objects
       
   543     TInt daynoteIndex = 0; // to insert day notes in correct order...
       
   544 	delete iPrevUid;    
       
   545 	iPrevUid = NULL;
       
   546     
       
   547     for( TInt eventArrayIndex = 0, count = aEntryArray.Count();
       
   548          eventArrayIndex < count;
       
   549          eventArrayIndex++ )
       
   550         {
       
   551         CAiCalendarPlugin2EventItem* eventItem = CAiCalendarPlugin2EventItem::NewL(
       
   552                                                         *aEntryArray[eventArrayIndex],
       
   553                                                         *iConstantData );
       
   554         CleanupStack::PushL( eventItem );
       
   555        
       
   556         // Multiple-day Todos contain multiple eventItems
       
   557         // Showing only one and deleting the rest
       
   558         if ( ( iPrevUid ) && ( eventItem->Type() == EPluginItemToDo ) 
       
   559         		&& ( iPrevUid->Compare( *( eventItem->iUid ) ) == 0 ) )
       
   560         	{
       
   561         	CleanupStack::PopAndDestroy( eventItem );
       
   562         	}
       
   563         else
       
   564         	{
       
   565         	delete iPrevUid;    
       
   566         	iPrevUid = NULL;
       
   567         	iPrevUid = eventItem->iUid->AllocL();        
       
   568     
       
   569         	// Append item ot correct array, method increments daynoteIndex if required
       
   570         	if( iEventData->AppendItemToCorrectArray( *eventItem,
       
   571         			daynoteIndex ) != KErrNone )
       
   572         		{
       
   573         		// Append not allowed, destroy item and proceed
       
   574         		CleanupStack::PopAndDestroy( eventItem );
       
   575         		}
       
   576         	else
       
   577         		{
       
   578         		// Item accepted and ownership transferred
       
   579         		CleanupStack::Pop( eventItem );
       
   580         		}
       
   581         	}
       
   582         }
       
   583     delete iPrevUid; 
       
   584     iPrevUid = NULL;
       
   585     iEventData->SortArrayByTime( iEventData->FutureItemArray() );
       
   586     iEventData->SortArrayByTime( iEventData->TomorrowEventArray() );
       
   587     }
       
   588 
       
   589 
       
   590 void CAICalendarPlugin2::PublishDataArraysL()
       
   591     {
       
   592 
       
   593     // We publish only to the first registered observer.
       
   594     // If needed edit the publishing helper function to
       
   595     // publish to all.
       
   596     if( iEventData->ObserverArray().Count() <= 0 )
       
   597         {
       
   598         // If no observers registered, return immediate
       
   599         iEventData->ClearDataArrays();
       
   600         return;
       
   601         }
       
   602     iCurrentObserver = (iEventData->ObserverArray())[0];
       
   603     iCurrentObserver->StartTransaction( reinterpret_cast<TInt32>(this) );
       
   604     iNewCollectedDataStore.Reset();
       
   605     iNewCollectedDataStore.Append( 0 ); // always append the not used zero
       
   606                                         // this because publishes start from 1
       
   607                                         // so we dont need to -1 everywhere
       
   608 
       
   609     /**************************************************************************
       
   610      *  Current publish order description, based on the Active Idle UI spec
       
   611      *
       
   612      *  Last update date: 19/09/2006, UI Spec date 08/09/2006
       
   613      *
       
   614      *  --- Last change item was to swap 3 and 4. Pre calculation part is
       
   615      *  --- no longer required but left in the code so that they can be restored
       
   616      *  --- just by moving the for loop again, no other changes required.
       
   617      *
       
   618      *  Sections are accordingly numbered in the code below:
       
   619      *
       
   620      *  0) Publish "No (more calendar) events for today" if no (more)
       
   621      *     events today.
       
   622      *
       
   623      *  1) If there are on going meetings/appointments and extra room for these
       
   624      *     after all non timer and upcoming meetings have been published,
       
   625      *     publish as many on going events as fits in to the view. These
       
   626      *     are only published if there is left over space = low priority.
       
   627      *
       
   628      *  2) Publish as many timed events for today as fits in to view, but
       
   629      *     reserve space for todays non timed event if any. Reserve as many
       
   630      *     lines as is in the spec, currently up to 2 lines are reserved.
       
   631      *     These are top priority items.
       
   632      *
       
   633      *  3) Publish non timed event for today. Use all space left from 1), 2)
       
   634      *     and 3) if necessary. These are top priority items.
       
   635      *
       
   636      *  4) These are only published if there is left over space = low priority.
       
   637      *
       
   638      *  5) Publish empty content to the rest of the items.
       
   639      *
       
   640      *  NOTES: Care must be taken when changes are made to this system.
       
   641      *         Extensive testing recommended when making even the smallest
       
   642      *         change.
       
   643      *
       
   644      **************************************************************************/
       
   645 
       
   646     TInt lineUsage = 0;
       
   647     TInt publishIndex = 1; // publishes start from 1, because 0 is "reserved"
       
   648                            // according to spec! maybe to.do: add a setting for this.
       
   649     const TInt cstSpaceTakenByTimed = iEventData->SpaceTakenByTimedEvent();
       
   650     const TInt cstSpaceTakenByNonTimed = iEventData->SpaceTakenByNonTimedEvent();
       
   651     
       
   652     // SPACE VALUES INCLUDES CONSIDERATION TO 1 line - 2 lines space reservation
       
   653     const TInt cstTotalNonTimedTodaySpace = iEventData->NonTimedEventArray().Count() *
       
   654                                          cstSpaceTakenByNonTimed;
       
   655 
       
   656     const TInt cstMinLinesForTodayNonTimed = Min( cstTotalNonTimedTodaySpace,
       
   657                                                      iNonTimedItemReservation *
       
   658                                                      cstSpaceTakenByNonTimed );
       
   659                                  
       
   660                                  
       
   661     // Simplify total today item count, calculate it ready here
       
   662     const TInt cstTotalTimedTodayItemCount = iEventData->TotalTimedTodayItemCount();
       
   663 
       
   664     RArray<TAiCalendarFocusData>& focusDataArray = iEventData->FocusDataArray();
       
   665     focusDataArray.Reset();
       
   666 
       
   667     // First item always occupied by title line.
       
   668     TAiCalendarFocusData titleFocusItem;
       
   669     titleFocusItem.iType = EAI2CalOpenToday;
       
   670     focusDataArray.Append( titleFocusItem );
       
   671 
       
   672     TBool cleanInfo = ETrue;
       
   673     // The "+ 1" in "lineUsage + 1"
       
   674     //          and "upcoming2HrsIndex + nonTimedIndex + futureTimedIndex + futureNonTimedIndex + ongoingIndex + ongoing30Index + upcomingIndex + nonCalendarEventItemIndex + 1"
       
   675     // derives from the fact that we do not publish to index 0
       
   676     // it is specified as reserved.
       
   677 
       
   678     /**
       
   679      * 0)
       
   680      */
       
   681     if( iEventData->TotalTodayItemCount() == 0 &&
       
   682         iEventData->LongOngoingArray().Count() == 0 )
       
   683         {
       
   684         // hadExpiredEvents tells us if we had any events today, when
       
   685         // there are no upcoming event for today. Then we can choose 
       
   686         // proper text to display.
       
   687         
       
   688         Clean( EAICalendarPlugin2EventSubject, lineUsage + 1 );
       
   689         Clean( EAICalendarPlugin2EventLocation, lineUsage + 1 );
       
   690         Clean( EAICalendarPlugin2EventTimeStart, lineUsage + 1 );
       
   691         Clean( EAICalendarPlugin2EventTimeEnd, lineUsage + 1 );
       
   692         Clean( EAICalendarPlugin2EventTextSecondLine, lineUsage + 1 );
       
   693 
       
   694         if( ( iEventData->TomorrowEventArray().Count() > 0 ) &&
       
   695             ( iConstantData->iDaysToHandleAsNotToday == KAIRangeTomorrowOnly ) )
       
   696             {
       
   697             if ( !iConstantData->iUseAlternateInfoPublish )
       
   698                 {
       
   699                 CleanInfo();
       
   700                 }
       
   701             TTime eventTime = (iEventData->TomorrowEventArray())[0]->Time();
       
   702             // display "Next event tomorrow:"
       
   703             if( !( CompareChecksums( publishIndex,
       
   704                                      KAI2InternalIdForNextEventTomorrow ) ) )
       
   705                 {
       
   706                 PublishIconL( EAICalendarPlugin2NoEventsForToday, publishIndex );
       
   707                 iCurrentObserver->Publish( *this,
       
   708                                         EAICalendarPlugin2EventTextFirstLine,
       
   709                                         EAICalendarPlugin2NextEventTomorrow,
       
   710                                         lineUsage + 1 ); // Text line 1
       
   711                 iCurrentObserver->Publish( *this,
       
   712                                         EAICalendarPlugin2EventSubject,
       
   713                                         EAICalendarPlugin2NextEventTomorrow,
       
   714                                         lineUsage + 1 ); // Text line 1
       
   715                 iCurrentObserver->Publish( *this,
       
   716                                         EAICalendarPlugin2TimeStartAndSubject,
       
   717                                         EAICalendarPlugin2NextEventTomorrow,
       
   718                                         lineUsage + 1 ); // Text line 1
       
   719                 }
       
   720             ++lineUsage;
       
   721             ++publishIndex;
       
   722 
       
   723             TAiCalendarFocusData focusItem;
       
   724             focusItem.iType = EAI2CalOpenOnEventDay;
       
   725             focusItem.iEntryTime = eventTime;
       
   726             focusDataArray.Append( focusItem );
       
   727             }
       
   728         else if( ( ( iEventData->NotTodayItemArray().Count() > 0 ) &&
       
   729                    ( iConstantData->iDaysToHandleAsNotToday > 0 ) ) ||
       
   730                  ( ( iEventData->TomorrowEventArray().Count() > 0 ) &&
       
   731                    ( iConstantData->iDaysToHandleAsNotToday > KAIRangeTomorrowOnly ) ) )
       
   732             {
       
   733             if ( !iConstantData->iUseAlternateInfoPublish )
       
   734                 {
       
   735                 CleanInfo();
       
   736                 }
       
   737             TTime eventTime;
       
   738             if( iEventData->TomorrowEventArray().Count() > 0 )
       
   739                 {
       
   740                 eventTime = (iEventData->TomorrowEventArray())[0]->Time();
       
   741                 }
       
   742             else
       
   743                 {
       
   744                 eventTime = (iEventData->NotTodayItemArray())[0]->Time();
       
   745                 }
       
   746              
       
   747             // display "Next event(s):"
       
   748             if( iEventData->NotTodayItemArray().Count() == 1 )
       
   749                 {
       
   750                 if( !( CompareChecksums( publishIndex,
       
   751                                          KAI2InternalIdForNextEvent ) ) )
       
   752                     {
       
   753                     PublishIconL( EAICalendarPlugin2NoEventsForToday, publishIndex );
       
   754                     iCurrentObserver->Publish( *this,
       
   755                                             EAICalendarPlugin2EventTextFirstLine,
       
   756                                             EAICalendarPlugin2NextEvent,
       
   757                                             lineUsage + 1 ); // Text line 1
       
   758                     iCurrentObserver->Publish( *this,
       
   759                                             EAICalendarPlugin2EventSubject,
       
   760                                             EAICalendarPlugin2NextEvent,
       
   761                                             lineUsage + 1 ); // Text line 1
       
   762 					iCurrentObserver->Publish( *this,
       
   763 											EAICalendarPlugin2TimeStartAndSubject,
       
   764 											EAICalendarPlugin2NextEvent,
       
   765 											lineUsage + 1 ); // Text line 1
       
   766                     }
       
   767                 }
       
   768             else
       
   769                 {
       
   770                 if( !( CompareChecksums( publishIndex,
       
   771                                          KAI2InternalIdForNextEvents ) ) )
       
   772                     {
       
   773                     PublishIconL( EAICalendarPlugin2NoEventsForToday, publishIndex );
       
   774                     iCurrentObserver->Publish( *this,
       
   775                                             EAICalendarPlugin2EventTextFirstLine,
       
   776                                             EAICalendarPlugin2NextEvents,
       
   777                                             lineUsage + 1 ); // Text line 1
       
   778                     iCurrentObserver->Publish( *this,
       
   779                                             EAICalendarPlugin2EventSubject,
       
   780                                             EAICalendarPlugin2NextEvents,
       
   781                                             lineUsage + 1 ); // Text line 1
       
   782 					iCurrentObserver->Publish( *this,
       
   783 											EAICalendarPlugin2TimeStartAndSubject,
       
   784 											EAICalendarPlugin2NextEvents,
       
   785 											lineUsage + 1 ); // Text line 1
       
   786                     }
       
   787                 }
       
   788             ++lineUsage;
       
   789             ++publishIndex;
       
   790 
       
   791             TAiCalendarFocusData focusItem;
       
   792             focusItem.iType = EAI2CalOpenOnEventDay;
       
   793             focusItem.iEntryTime = eventTime;
       
   794             focusDataArray.Append( focusItem );
       
   795             }
       
   796         else if( ( iEventData->FutureItemArray().Count() > 0 ) ||
       
   797                     ( ( iEventData->TomorrowEventArray().Count() > 0 ) &&
       
   798                       ( iConstantData->iDaysToHandleAsNotToday == 0 ) ) )
       
   799             {
       
   800             if ( !iConstantData->iUseAlternateInfoPublish )
       
   801                 {
       
   802                 CleanInfo();
       
   803                 }
       
   804             CAiCalendarPlugin2EventItem* item = NULL;
       
   805             if( ( iEventData->TomorrowEventArray().Count() > 0 ) &&
       
   806                 ( iConstantData->iDaysToHandleAsNotToday == 0 ) )
       
   807                 {
       
   808                 item = (iEventData->TomorrowEventArray())[0];
       
   809                 }
       
   810             else
       
   811                 {
       
   812                 item = (iEventData->FutureItemArray())[0];
       
   813                 }
       
   814             
       
   815             TTime eventTime = item->Time();
       
   816             const TDesC& nextOn = iConstantData->MakeEventOnL(eventTime);
       
   817             
       
   818             if( !( CompareChecksums( 0, item->CreateChecksumFromString( nextOn ) ) ) )
       
   819                 {
       
   820                 // this change publish next event information to calendar info text instead of calendar entry text
       
   821                 // some languages needs two rows for publishing
       
   822                 cleanInfo = EFalse;
       
   823                 // display "Next event on: [day of the week] [date]"
       
   824                 PublishIconL( EAICalendarPlugin2NoMoreEventsForToday, 0, EAICalendarPlugin2InfoIcon );
       
   825                 iCurrentObserver->Publish( *this, EAICalendarPlugin2InfoText, nextOn, 0 );
       
   826                 }
       
   827             ++lineUsage;
       
   828             ++publishIndex;
       
   829 
       
   830             TAiCalendarFocusData focusItem;
       
   831             focusItem.iType = EAI2CalOpenOnEventDay;
       
   832             focusItem.iEntryTime = eventTime;
       
   833             focusDataArray.Append( focusItem );
       
   834             /**
       
   835              * 5) Clean the rest
       
   836              */
       
   837             for( ; publishIndex <= iActualLinesInUse; ++publishIndex )
       
   838                 {
       
   839                 CleanAll( publishIndex );
       
   840 
       
   841                 TAiCalendarFocusData focusItem2;
       
   842                 focusItem2.iType = EAI2CalOpenToday;
       
   843                 focusDataArray.Append( focusItem2 );
       
   844                 }
       
   845 
       
   846             if( ( iPublishedDataStore.Count() == 0 ) ||
       
   847                 ( iPublishedDataStore.Count() != iNewCollectedDataStore.Count() ) )
       
   848                 {
       
   849                 iPublishedDataStore.Reset();
       
   850                 for( TInt i = 0; i < iNewCollectedDataStore.Count(); ++i )
       
   851                     {
       
   852                     iPublishedDataStore.Append( iNewCollectedDataStore[i] );
       
   853                     }
       
   854                 iCurrentObserver->Commit( reinterpret_cast<TInt32>(this) );
       
   855                 }
       
   856             else
       
   857                 {
       
   858                 iCurrentObserver->CancelTransaction( reinterpret_cast<TInt32>(this) );
       
   859                 }
       
   860 
       
   861             iEventData->ClearDataArrays();
       
   862             return;
       
   863             }
       
   864         else if( !iConstantData->iUseAlternatePublish )
       
   865             {
       
   866             if ( iConstantData->iUseAlternateInfoPublish )
       
   867                 {
       
   868                 Clean( EAICalendarPlugin2EventTextFirstLine, lineUsage + 1 );
       
   869                 Clean( EAICalendarPlugin2TimeStartAndSubject, lineUsage + 1 );
       
   870                 }
       
   871             else
       
   872                 {
       
   873                 CleanInfo();
       
   874                 }
       
   875             // display ""No Calendar events for today or next 7 days"
       
   876             // or "No more Calendar events for today or next 7 days"
       
   877             if( !iEventData->HadExpiredEvents() )
       
   878                 {
       
   879                 if( !( CompareChecksums( publishIndex,
       
   880                                          KAI2InternalIdForNoMoreEvents ) ) )
       
   881                     {
       
   882                     if( !iConstantData->iUseAlternateInfoPublish )
       
   883                         {
       
   884                         PublishIconL( EAICalendarPlugin2NoEventsForToday, 
       
   885                                 publishIndex );
       
   886                         iCurrentObserver->Publish( *this,
       
   887                                 EAICalendarPlugin2EventTextFirstLine,
       
   888                                 EAICalendarPlugin2NoEventsForToday,
       
   889                                 lineUsage + 1 ); // Text line 1
       
   890                         iCurrentObserver->Publish( *this,
       
   891                                 EAICalendarPlugin2EventSubject,
       
   892                                 EAICalendarPlugin2NoEventsForToday,
       
   893                                 lineUsage + 1 ); // Text line 1                    
       
   894                         }
       
   895                     // In case theme instructs us we need to publish the status
       
   896                     // texts and icons to a different location
       
   897                     else
       
   898                         {
       
   899                         cleanInfo = EFalse;
       
   900                         PublishIconL( EAICalendarPlugin2NoEventsForToday,
       
   901                                 0,
       
   902                                 EAICalendarPlugin2InfoIcon);
       
   903                         iCurrentObserver->Publish( *this,
       
   904                                 EAICalendarPlugin2InfoText,
       
   905                                 EAICalendarPlugin2NoEventsForToday,
       
   906                                 0); // Text line 1                    
       
   907                         }
       
   908                     }
       
   909                 }
       
   910             else
       
   911                 {
       
   912                 if( !( CompareChecksums( publishIndex,
       
   913                                          KAI2InternalIdForNoEvents ) ) )
       
   914                     {
       
   915                     if( !iConstantData->iUseAlternateInfoPublish )
       
   916                         {
       
   917                         PublishIconL( EAICalendarPlugin2NoEventsForToday, publishIndex );
       
   918                         iCurrentObserver->Publish( *this,
       
   919                                 EAICalendarPlugin2EventTextFirstLine,
       
   920                                 EAICalendarPlugin2NoMoreEventsForToday,
       
   921                                 lineUsage + 1 ); // Text line 1
       
   922                         iCurrentObserver->Publish( *this,
       
   923                                 EAICalendarPlugin2EventSubject,
       
   924                                 EAICalendarPlugin2NoMoreEventsForToday,
       
   925                                 lineUsage + 1 ); // Text line 1                    
       
   926                         }
       
   927                     // In case theme instructs us we need to publish the status
       
   928                     // texts and icons to a different location
       
   929                     else
       
   930                         {
       
   931                         cleanInfo = EFalse;
       
   932                         PublishIconL( EAICalendarPlugin2NoEventsForToday,
       
   933                                 0,
       
   934                                 EAICalendarPlugin2InfoIcon);
       
   935                         iCurrentObserver->Publish( *this,
       
   936                                 EAICalendarPlugin2InfoText,
       
   937                                 EAICalendarPlugin2NoMoreEventsForToday,
       
   938                                 0 ); // Text line 1         
       
   939                         }
       
   940                     }
       
   941                 }
       
   942             ++lineUsage;
       
   943             ++publishIndex;
       
   944 
       
   945             TAiCalendarFocusData focusItem;
       
   946             focusItem.iType = EAI2CalOpenToday;
       
   947             focusDataArray.Append( focusItem );
       
   948             }
       
   949         }
       
   950 
       
   951     const TInt cstMaxLinesForTimedEvents =
       
   952                             ( iActualLinesInUse - cstMinLinesForTodayNonTimed );
       
   953 
       
   954     /**
       
   955      * -1) Really old ongoing timed events need full set of info.
       
   956      */
       
   957     const TInt cstLinesReserved3 =
       
   958                                GetTimedArrayLineNeed( iEventData->Upcoming2HrsArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   959                                GetTimedArrayLineNeed( iEventData->Ongoing30MinArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   960                                GetTimedArrayLineNeed( iEventData->UpcomingArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   961                                GetTimedArrayLineNeed( iEventData->OngoingArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   962                                cstTotalNonTimedTodaySpace;
       
   963     const TInt startIndex3 = CalculateStartIndexBackwards(
       
   964                                   iEventData->LongOngoingArray(),
       
   965                                   iActualLinesInUse - cstLinesReserved3,
       
   966                                   ( iConstantData->iUseAlternatePublish ?
       
   967                                     1 :iEventData->SpaceTakenByTimedEvent() ),
       
   968                                   EFalse );
       
   969     if( startIndex3 >= 0 )
       
   970         {
       
   971         PublishTodayTimedItemsForArrayL(
       
   972                iEventData->LongOngoingArray(),
       
   973                publishIndex, // reference passed and updated inside
       
   974                lineUsage, // reference passed and updated inside
       
   975                cstMaxLinesForTimedEvents,
       
   976                startIndex3,
       
   977             cstLinesReserved3 );
       
   978         }
       
   979 
       
   980     /**
       
   981      * 1) Ongoing today timed events need full set of info.
       
   982      */
       
   983     const TInt cstLinesReserved =
       
   984                                GetTimedArrayLineNeed( iEventData->Upcoming2HrsArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   985                                GetTimedArrayLineNeed( iEventData->Ongoing30MinArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   986                                GetTimedArrayLineNeed( iEventData->UpcomingArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
   987                                cstTotalNonTimedTodaySpace;
       
   988     const TInt startIndex = CalculateStartIndexBackwards(
       
   989                                   iEventData->OngoingArray(),
       
   990                                   iActualLinesInUse - cstLinesReserved,
       
   991                                   ( iConstantData->iUseAlternatePublish ?
       
   992                                     1 :iEventData->SpaceTakenByTimedEvent() ),
       
   993                                   ETrue );
       
   994 
       
   995     if( startIndex >= 0 )
       
   996         {
       
   997         PublishTodayTimedItemsForArrayL(
       
   998                iEventData->OngoingArray(),
       
   999                publishIndex, // reference passed and updated inside
       
  1000                lineUsage, // reference passed and updated inside
       
  1001                cstMaxLinesForTimedEvents,
       
  1002                startIndex,
       
  1003                cstLinesReserved );
       
  1004         }
       
  1005 
       
  1006     /**
       
  1007      * Ongoing not older than 30min today timed events.
       
  1008      */
       
  1009     const TInt cstLinesReserved2 =
       
  1010                              GetTimedArrayLineNeed( iEventData->Upcoming2HrsArray(), iEventData->SpaceTakenByTimedEvent() ) +
       
  1011                              cstMinLinesForTodayNonTimed;
       
  1012     const TInt startIndex2 = CalculateStartIndexBackwards(
       
  1013                                   iEventData->Ongoing30MinArray(),
       
  1014                                   iActualLinesInUse - cstLinesReserved2,
       
  1015                                  iEventData->SpaceTakenByTimedEvent() ,
       
  1016                                   ETrue );
       
  1017 
       
  1018     if( startIndex2 >= 0 )
       
  1019         {
       
  1020         PublishTodayTimedItemsForArrayL(
       
  1021                iEventData->Ongoing30MinArray(),
       
  1022                publishIndex, // reference passed and updated inside
       
  1023                lineUsage, // reference passed and updated inside
       
  1024                cstMaxLinesForTimedEvents,
       
  1025                startIndex2,
       
  1026                cstLinesReserved2 );
       
  1027         }
       
  1028         
       
  1029     /**
       
  1030      * Upcoming today timed events.
       
  1031      */
       
  1032     PublishTodayTimedItemsForArrayL(
       
  1033            iEventData->Upcoming2HrsArray(),
       
  1034            publishIndex, // reference passed and updated inside
       
  1035            lineUsage, // reference passed and updated inside
       
  1036            cstMaxLinesForTimedEvents );
       
  1037                
       
  1038     PublishTodayTimedItemsForArrayL(
       
  1039            iEventData->UpcomingArray(),
       
  1040            publishIndex, // reference passed and updated inside
       
  1041            lineUsage, // reference passed and updated inside
       
  1042            cstMaxLinesForTimedEvents );
       
  1043 
       
  1044     /**
       
  1045      * 3) Non timed events only need combined icon and subject/location string.
       
  1046      *    Other fields are cleaned.
       
  1047      */
       
  1048     for( TInt nonTimedIndex = 0; ( nonTimedIndex < iEventData->NonTimedEventArray().Count() ) &&
       
  1049            ( lineUsage + cstSpaceTakenByNonTimed <= iActualLinesInUse )
       
  1050          ; ++nonTimedIndex )
       
  1051         {
       
  1052         if( !( CompareChecksums( publishIndex,
       
  1053                                  iEventData->NonTimedEventArray()[nonTimedIndex]->Checksum() ) ) )
       
  1054             {
       
  1055             PublishIconL( iEventData->NonTimedEventArray()[nonTimedIndex]->IconId(), publishIndex );
       
  1056 
       
  1057             Clean( EAICalendarPlugin2EventTextSecondLine, publishIndex );
       
  1058 
       
  1059             PublishNonTimedEventTexts( *iEventData->NonTimedEventArray()[nonTimedIndex],
       
  1060                                   publishIndex );
       
  1061             }
       
  1062         lineUsage += cstSpaceTakenByNonTimed;
       
  1063         ++publishIndex;
       
  1064         focusDataArray.Append( iEventData->NonTimedEventArray()[nonTimedIndex]->FocusData() );
       
  1065         }
       
  1066 
       
  1067     if( iConstantData->iDaysToHandleAsNotToday > 0 )
       
  1068         {
       
  1069         /**
       
  1070          * 4) Future items
       
  1071          */
       
  1072         PublishFutureItemsForArrayL(
       
  1073                 iEventData->TomorrowEventArray(),
       
  1074                 publishIndex, // reference passed and updated inside
       
  1075                 lineUsage, // reference passed and updated inside
       
  1076                 iActualLinesInUse);
       
  1077                 
       
  1078         PublishFutureItemsForArrayL(
       
  1079                 iEventData->NotTodayItemArray(),
       
  1080                 publishIndex, // reference passed and updated inside
       
  1081                 lineUsage, // reference passed and updated inside
       
  1082                 iActualLinesInUse);
       
  1083         }
       
  1084 
       
  1085     /**
       
  1086      * 5) Clean the rest
       
  1087      */
       
  1088     for( ; publishIndex <= iActualLinesInUse; ++publishIndex )
       
  1089         {
       
  1090         CleanAll( publishIndex );
       
  1091 
       
  1092         TAiCalendarFocusData focusItem;
       
  1093         focusItem.iType = EAI2CalOpenToday;
       
  1094         focusDataArray.Append( focusItem );
       
  1095         }
       
  1096 
       
  1097     if ( cleanInfo )
       
  1098         {
       
  1099         CleanInfo();        
       
  1100         }
       
  1101     
       
  1102     if( ( iPublishedDataStore.Count() == 0 ) ||
       
  1103         ( iPublishedDataStore.Count() != iNewCollectedDataStore.Count() ) )
       
  1104         {
       
  1105         iPublishedDataStore.Reset();
       
  1106         for( TInt i = 0; i < iNewCollectedDataStore.Count(); ++i )
       
  1107             {
       
  1108             iPublishedDataStore.Append( iNewCollectedDataStore[i] );
       
  1109             }
       
  1110         iCurrentObserver->Commit( reinterpret_cast<TInt32>(this) );
       
  1111         }
       
  1112     else
       
  1113         {
       
  1114         iCurrentObserver->CancelTransaction( reinterpret_cast<TInt32>(this) );
       
  1115         }
       
  1116         
       
  1117     iEventData->ClearDataArrays();
       
  1118     
       
  1119     }
       
  1120 
       
  1121 void CAICalendarPlugin2::PublishTodayTimedItemsForArrayL(
       
  1122                RPointerArray<CAiCalendarPlugin2EventItem>& aArray,
       
  1123                TInt& aPublishIndex,
       
  1124                TInt& aLineUsage,
       
  1125                TInt aMaxLinesAvailable,
       
  1126                TInt aArrayOffset,
       
  1127                TInt aExtraLineReservation )
       
  1128     {
       
  1129     TInt spaceTakenByNext = GetTimedItemLineNeed( aArray, aArrayOffset );
       
  1130     if( ( ( &aArray == &iEventData->OngoingArray() ) && !iConstantData->iUseAlternatePublish ) ||
       
  1131           &aArray == &iEventData->Ongoing30MinArray() )
       
  1132         {
       
  1133         spaceTakenByNext =iEventData->SpaceTakenByTimedEvent();
       
  1134         }
       
  1135     TInt spaceTaken = aLineUsage;
       
  1136     TInt index = 0;
       
  1137     for( ; ( ( index + aArrayOffset ) < aArray.Count() ) &&
       
  1138            ( ( iActualLinesInUse - ( aExtraLineReservation + spaceTakenByNext + spaceTaken ) ) >= 0 ) &&
       
  1139            ( ( aLineUsage + spaceTakenByNext ) <= aMaxLinesAvailable )
       
  1140          ; ++index )
       
  1141         {
       
  1142         const TInt pbIndex = index + aArrayOffset;
       
  1143 
       
  1144         if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum(), ETrue ) ) )
       
  1145             {
       
  1146             PublishIconL( aArray[pbIndex]->IconId(), aPublishIndex );
       
  1147             }
       
  1148 
       
  1149         if( aArray[pbIndex]->Type() == EPluginItemOlderOnGoingEvent &&
       
  1150             iConstantData->iUseAlternatePublish )
       
  1151             {
       
  1152             if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum() ) ) )
       
  1153                 {
       
  1154                 iCurrentObserver->Clean( *this,
       
  1155                                          EAICalendarPlugin2EventTextSecondLine,
       
  1156                                          aPublishIndex );
       
  1157                                          
       
  1158                 PublishTimedEventTexts( *aArray[pbIndex], aPublishIndex, aLineUsage );
       
  1159                 }
       
  1160 	        else
       
  1161 	            {
       
  1162 	            // increase line usage only
       
  1163 	            aLineUsage += spaceTakenByNext;
       
  1164 	            }
       
  1165             }
       
  1166         else
       
  1167             {
       
  1168             if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum() ) ) )
       
  1169                 {
       
  1170                 iCurrentObserver->Clean( *this,
       
  1171                                      EAICalendarPlugin2EventTextFirstLine,
       
  1172                                      aPublishIndex );
       
  1173                                  
       
  1174                 PublishTimeRelatedTexts( *aArray[pbIndex], aPublishIndex, aLineUsage );
       
  1175                 }
       
  1176 	        else
       
  1177 	            {
       
  1178 	            // increase line usage only
       
  1179 	            aLineUsage += spaceTakenByNext;
       
  1180 	            }
       
  1181             }
       
  1182 
       
  1183         ++aPublishIndex;
       
  1184         iEventData->FocusDataArray().Append( aArray[pbIndex]->FocusData() );
       
  1185         spaceTaken += spaceTakenByNext;
       
  1186         if( ( ( &aArray == &iEventData->OngoingArray() ) && !iConstantData->iUseAlternatePublish ) ||
       
  1187             &aArray == &iEventData->Ongoing30MinArray() )
       
  1188             {
       
  1189             spaceTakenByNext =iEventData->SpaceTakenByTimedEvent();
       
  1190             }
       
  1191         else
       
  1192             {
       
  1193             spaceTakenByNext = GetTimedItemLineNeed( aArray, pbIndex + 1 );
       
  1194             }
       
  1195         }
       
  1196     }
       
  1197     
       
  1198 void CAICalendarPlugin2::PublishFutureItemsForArrayL(
       
  1199                RPointerArray<CAiCalendarPlugin2EventItem>& aArray,
       
  1200                TInt& aPublishIndex,
       
  1201                TInt& aLineUsage,
       
  1202                TInt aMaxLinesAvailable )
       
  1203     {
       
  1204     TInt index = 0;
       
  1205     
       
  1206     TInt spaceTakenByNext = GetTimedItemLineNeed( aArray, index );
       
  1207 
       
  1208     for( ; ( index < aArray.Count() )
       
  1209          ; ++index )
       
  1210         {
       
  1211         if( !( ( aLineUsage + spaceTakenByNext ) <= aMaxLinesAvailable ) )
       
  1212             {
       
  1213             spaceTakenByNext = GetTimedItemLineNeed( aArray, index + 1 );
       
  1214             continue;
       
  1215             }
       
  1216         if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum(), ETrue ) ) )
       
  1217             {
       
  1218             PublishIconL( aArray[index]->IconId(), aPublishIndex );
       
  1219             }
       
  1220 
       
  1221         if( aArray[index]->Type() == EPluginItemMeeting && iConstantData->iUseAlternatePublish )
       
  1222             {
       
  1223             if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum() ) ) )
       
  1224                 {
       
  1225                 iCurrentObserver->Clean( *this,
       
  1226                                          EAICalendarPlugin2EventTextSecondLine,
       
  1227                                          aPublishIndex );
       
  1228                                      
       
  1229                 PublishTimedEventTexts( *aArray[index], aPublishIndex, aLineUsage );
       
  1230                 }
       
  1231             else
       
  1232                 {
       
  1233                 // increase line usage only
       
  1234                 aLineUsage += spaceTakenByNext;
       
  1235                 }
       
  1236             }
       
  1237         else if( aArray[index]->Type() == EPluginItemMeeting )
       
  1238             {
       
  1239             if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum() ) ) )
       
  1240                 {
       
  1241                 PublishTimeRelatedTexts( *aArray[index], aPublishIndex, aLineUsage );
       
  1242                 }
       
  1243             else
       
  1244                 {
       
  1245                 // increase line usage only
       
  1246                 aLineUsage += spaceTakenByNext;
       
  1247                 }
       
  1248             }
       
  1249         else
       
  1250             {
       
  1251             if( !( CompareChecksums( aPublishIndex, aArray[index]->Checksum() ) ) )
       
  1252                 {
       
  1253                 Clean( EAICalendarPlugin2EventTextSecondLine, aPublishIndex );
       
  1254 
       
  1255                 PublishNonTimedEventTexts( *aArray[index],
       
  1256                                            aPublishIndex );
       
  1257                 }
       
  1258             // increase line usage
       
  1259                 aLineUsage += iEventData->SpaceTakenByNonTimedEvent();
       
  1260             }
       
  1261 
       
  1262         ++aPublishIndex;
       
  1263 
       
  1264         iEventData->FocusDataArray().Append( aArray[index]->FocusData() );
       
  1265         spaceTakenByNext = GetTimedItemLineNeed( aArray, index + 1 );
       
  1266         }
       
  1267     
       
  1268     }
       
  1269 
       
  1270 
       
  1271 void CAICalendarPlugin2::CleanAll( TInt aIndex )
       
  1272     {
       
  1273     CleanTimeRelated( aIndex );
       
  1274     CleanTexts( aIndex );
       
  1275     CleanIcon( aIndex );
       
  1276     }
       
  1277 
       
  1278 void CAICalendarPlugin2::CleanTimeRelated( TInt aIndex )
       
  1279     {
       
  1280     iCurrentObserver->Clean( *this,
       
  1281                           EAICalendarPlugin2EventTextFirstLine,
       
  1282                           aIndex );
       
  1283     iCurrentObserver->Clean( *this,
       
  1284                           EAICalendarPlugin2EventTimeStart,
       
  1285                           aIndex );
       
  1286     iCurrentObserver->Clean( *this,
       
  1287                           EAICalendarPlugin2EventTimeEnd,
       
  1288                           aIndex );
       
  1289     iCurrentObserver->Clean( *this,
       
  1290                            EAICalendarPlugin2TimeStartAndSubject,
       
  1291                            aIndex);
       
  1292     }
       
  1293 
       
  1294 void CAICalendarPlugin2::CleanTexts( TInt aIndex )
       
  1295     {
       
  1296     iCurrentObserver->Clean( *this,
       
  1297                           EAICalendarPlugin2EventTextSecondLine,
       
  1298                           aIndex );
       
  1299     iCurrentObserver->Clean( *this,
       
  1300                           EAICalendarPlugin2EventSubject,
       
  1301                           aIndex );
       
  1302     iCurrentObserver->Clean( *this,
       
  1303                           EAICalendarPlugin2EventLocation,
       
  1304                           aIndex );
       
  1305     iCurrentObserver->Clean( *this,
       
  1306                            EAICalendarPlugin2TimeStartAndSubject,
       
  1307                            aIndex);   
       
  1308     }
       
  1309 
       
  1310 void CAICalendarPlugin2::CleanIcon( TInt aIndex )
       
  1311     {
       
  1312     iCurrentObserver->Clean( *this,
       
  1313                           EAICalendarPlugin2EventIcon,
       
  1314                           aIndex );
       
  1315     }
       
  1316 
       
  1317 void CAICalendarPlugin2::Clean( TInt aItem, TInt aIndex )
       
  1318     {
       
  1319     iCurrentObserver->Clean( *this,
       
  1320                              aItem,
       
  1321                              aIndex );
       
  1322     }
       
  1323 
       
  1324 void CAICalendarPlugin2::CleanInfo()
       
  1325     {
       
  1326     iCurrentObserver->Clean( *this,
       
  1327             EAICalendarPlugin2InfoText,
       
  1328             0);
       
  1329     
       
  1330     iCurrentObserver->Clean( *this,
       
  1331             EAICalendarPlugin2InfoIcon,
       
  1332             0);    
       
  1333     }
       
  1334 
       
  1335 void CAICalendarPlugin2::PublishTimedEventTexts( CAiCalendarPlugin2EventItem& aData,
       
  1336                                             TInt aIndex,
       
  1337                                             TInt& aLineUsage )
       
  1338     {
       
  1339     // here the first line - second line mix is intentional. see below comment
       
  1340     if( aData.FirstLineText() != KNullDesC )
       
  1341         {
       
  1342         iCurrentObserver->Publish( *this,
       
  1343                                    EAICalendarPlugin2EventTextFirstLine,
       
  1344                                    aData.FirstLineText(),
       
  1345                                    aIndex );
       
  1346         ++aLineUsage;
       
  1347         }
       
  1348     else
       
  1349         {
       
  1350         iCurrentObserver->Clean( *this,
       
  1351                                  EAICalendarPlugin2EventTextFirstLine,
       
  1352                                  aIndex );
       
  1353         }
       
  1354         
       
  1355     // Separate field publishes
       
  1356     iCurrentObserver->Publish( *this,
       
  1357                                EAICalendarPlugin2EventTimeStart,
       
  1358                                aData.StartTimeText(),
       
  1359                                aIndex );
       
  1360     iCurrentObserver->Publish( *this,
       
  1361                                EAICalendarPlugin2EventTimeEnd,
       
  1362                                aData.EndTimeText(),
       
  1363                                aIndex );
       
  1364     iCurrentObserver->Publish( *this,
       
  1365                                EAICalendarPlugin2EventSubject,
       
  1366                                aData.SubjectText(),
       
  1367                                aIndex );
       
  1368     iCurrentObserver->Publish( *this,
       
  1369                                EAICalendarPlugin2EventLocation,
       
  1370                                aData.LocationText(),
       
  1371                                aIndex );
       
  1372     iCurrentObserver->Publish( *this,
       
  1373                 EAICalendarPlugin2TimeStartAndSubject,
       
  1374                 aData.SubjectTimeString( ETrue ),
       
  1375                 aIndex);
       
  1376     }
       
  1377 
       
  1378 void CAICalendarPlugin2::PublishNonTimedEventTexts( CAiCalendarPlugin2EventItem& aData,
       
  1379                                                TInt aIndex )
       
  1380     {
       
  1381     // here the first line - second line mix is intentional. see above comment
       
  1382     iCurrentObserver->Publish( *this,
       
  1383                                EAICalendarPlugin2EventTextFirstLine,
       
  1384                                aData.SecondLineText(),
       
  1385                                aIndex );
       
  1386                                
       
  1387     // Separate field publishes
       
  1388     if( aData.StartTimeText().Length() > 0 )
       
  1389         {
       
  1390         iCurrentObserver->Publish( *this,
       
  1391                                    EAICalendarPlugin2EventTimeStart,
       
  1392                                    aData.StartTimeText(),
       
  1393                                    aIndex );
       
  1394         }
       
  1395     else
       
  1396         {
       
  1397         Clean( EAICalendarPlugin2EventTimeStart, aIndex );
       
  1398         }
       
  1399     if( aData.EndTimeText().Length() > 0 )
       
  1400         {
       
  1401         iCurrentObserver->Publish( *this,
       
  1402                                    EAICalendarPlugin2EventTimeEnd,
       
  1403                                    aData.EndTimeText(),
       
  1404                                    aIndex );
       
  1405         }
       
  1406     else
       
  1407         {
       
  1408         Clean( EAICalendarPlugin2EventTimeEnd, aIndex );
       
  1409         }
       
  1410     iCurrentObserver->Publish( *this,
       
  1411                                EAICalendarPlugin2EventSubject,
       
  1412                                aData.SubjectText(),
       
  1413                                aIndex );
       
  1414     iCurrentObserver->Publish( *this,
       
  1415                                EAICalendarPlugin2EventLocation,
       
  1416                                aData.LocationText(),
       
  1417                                aIndex );   
       
  1418        
       
  1419     iCurrentObserver->Publish( *this,
       
  1420                 EAICalendarPlugin2TimeStartAndSubject,
       
  1421                 aData.SubjectTimeString( ETrue ),
       
  1422                                aIndex );
       
  1423     }
       
  1424 
       
  1425 void CAICalendarPlugin2::PublishTimeRelatedTexts( CAiCalendarPlugin2EventItem& aData,
       
  1426                                              TInt aIndex,
       
  1427                                              TInt& aLineUsage )
       
  1428     {
       
  1429     // here the first line - second line mix is intentional. see above comments
       
  1430     if( aData.SecondLineText() != KNullDesC )
       
  1431         {
       
  1432         iCurrentObserver->Publish( *this,
       
  1433                                    EAICalendarPlugin2EventTextSecondLine,
       
  1434                                    aData.SecondLineText(),
       
  1435                                    aIndex );
       
  1436         ++aLineUsage;
       
  1437         }
       
  1438     else if( aData.FirstLineText() != KNullDesC )
       
  1439         {
       
  1440         iCurrentObserver->Publish( *this,
       
  1441                                    EAICalendarPlugin2EventTextSecondLine,
       
  1442                                    aData.FirstLineText(),
       
  1443                                    aIndex );
       
  1444         ++aLineUsage;
       
  1445         }
       
  1446     else
       
  1447         {
       
  1448         iCurrentObserver->Clean( *this,
       
  1449                                  EAICalendarPlugin2EventTextSecondLine,
       
  1450                                  aIndex );
       
  1451         }
       
  1452         
       
  1453     // Separate field publishes
       
  1454     iCurrentObserver->Publish( *this,
       
  1455                                EAICalendarPlugin2EventTimeStart,
       
  1456                                aData.StartTimeText(),
       
  1457                                aIndex );
       
  1458     iCurrentObserver->Publish( *this,
       
  1459                                EAICalendarPlugin2EventTimeEnd,
       
  1460                                aData.EndTimeText(),
       
  1461                                aIndex );
       
  1462     iCurrentObserver->Publish( *this,
       
  1463                                EAICalendarPlugin2EventSubject,
       
  1464                                aData.SubjectText(),
       
  1465                                aIndex );
       
  1466     iCurrentObserver->Publish( *this,
       
  1467                                EAICalendarPlugin2EventLocation,
       
  1468                                aData.LocationText(),
       
  1469                                aIndex );
       
  1470     
       
  1471     iCurrentObserver->Publish( *this,
       
  1472                 EAICalendarPlugin2TimeStartAndSubject,
       
  1473                 aData.SubjectTimeString( ETrue ),
       
  1474                                aIndex );
       
  1475     }
       
  1476 
       
  1477 void CAICalendarPlugin2::PublishIconL( const TInt aIconId, TInt aIndex, TInt aContent )
       
  1478     {
       
  1479     CGulIcon* icon = NULL;
       
  1480      CFbsBitmap* bitmap3 = NULL;
       
  1481      CFbsBitmap* mask3 = NULL;
       
  1482      TAknsItemID skinIconId;
       
  1483      
       
  1484      HBufC* bitmapFile = iCalendarIconFileName;
       
  1485      
       
  1486      TInt bitmapId = 0;
       
  1487      TInt maskId = 0;
       
  1488 
       
  1489      // Map events to MBM id's and load from correct file
       
  1490      switch( aIconId )
       
  1491          {
       
  1492          case EAICalendarPlugin2IconAppt:
       
  1493          case EAICalendarPlugin2IconMeetingAccepted:
       
  1494          case EAICalendarPlugin2IconMeetingNotAnswered:
       
  1495          case EAICalendarPlugin2IconMeetingTentative:
       
  1496              {
       
  1497              skinIconId.Set( KAknsIIDQgnIndiCdrMeeting ); 
       
  1498              bitmapId = EMbmCalendarQgn_indi_cdr_meeting;
       
  1499              maskId = EMbmCalendarQgn_indi_cdr_meeting_mask;
       
  1500              break;
       
  1501              }
       
  1502          case EAICalendarPlugin2IconTodo: // Uncompleted To-Do icon
       
  1503              {
       
  1504              skinIconId.Set( KAknsIIDQgnIndiCdrTodo );
       
  1505              bitmapId = EMbmCalendarQgn_indi_cdr_todo;
       
  1506              maskId = EMbmCalendarQgn_indi_cdr_todo_mask;
       
  1507              break;
       
  1508              }
       
  1509          case EAICalendarPlugin2IconMemo: // Memo icon
       
  1510              {
       
  1511              skinIconId.Set( KAknsIIDQgnIndiCdrReminder );
       
  1512              bitmapId = EMbmCalendarQgn_indi_cdr_reminder;
       
  1513              maskId = EMbmCalendarQgn_indi_cdr_reminder_mask;
       
  1514              break;
       
  1515              }
       
  1516          case EAICalendarPlugin2IconAnniv: // Anniversary icon
       
  1517              {
       
  1518              skinIconId.Set( KAknsIIDQgnIndiCdrBirthday );
       
  1519              bitmapId = EMbmCalendarQgn_indi_cdr_birthday;
       
  1520              maskId = EMbmCalendarQgn_indi_cdr_birthday_mask;
       
  1521              break;
       
  1522              }
       
  1523          case EAICalendarPlugin2NoMoreEventsForToday:
       
  1524          case EAICalendarPlugin2NoEventsForToday:
       
  1525              {
       
  1526              skinIconId.Set( KAknsIIDQgnIndiAiCale );
       
  1527              bitmapId = EMbmAicalendarplugin2Qgn_indi_ai_cale;
       
  1528              maskId = EMbmAicalendarplugin2Qgn_indi_ai_cale_mask;
       
  1529              bitmapFile = iPluginIconFileName;
       
  1530              break;
       
  1531              }
       
  1532          default:
       
  1533              {
       
  1534              return;
       
  1535              }
       
  1536          }
       
  1537              
       
  1538      CreateBitmapSkinnedIconL( skinIconId, 
       
  1539                                *bitmapFile, 
       
  1540                                bitmapId, 
       
  1541                                maskId,
       
  1542                                bitmap3, mask3 );
       
  1543                            
       
  1544      // icon will own the bitmaps
       
  1545      CleanupStack::PushL( bitmap3 );
       
  1546      CleanupStack::PushL( mask3 );
       
  1547      icon = CGulIcon::NewL( bitmap3, mask3 );
       
  1548      CleanupStack::Pop( 2, bitmap3 );
       
  1549          
       
  1550      TInt err = iCurrentObserver->PublishPtr( *this,
       
  1551                                 aContent,
       
  1552                                 icon,
       
  1553                                 aIndex );
       
  1554      if( err != KErrNone )
       
  1555          {
       
  1556          delete icon;
       
  1557          }
       
  1558     }
       
  1559 
       
  1560 void CAICalendarPlugin2::PublishIconL( const TInt aIconId, TInt aIndex )
       
  1561     {
       
  1562     PublishIconL( aIconId, aIndex, EAICalendarPlugin2EventIcon );
       
  1563     }
       
  1564 
       
  1565 TBool CAICalendarPlugin2::CompareChecksums( 
       
  1566                 TInt aChecksumIndex,
       
  1567                 TInt aItemChecksum,
       
  1568                 TBool aIsIcon )
       
  1569     {
       
  1570     if( !aIsIcon )
       
  1571         {
       
  1572         iNewCollectedDataStore.Append( aItemChecksum );
       
  1573         }
       
  1574     if( ( iPublishedDataStore.Count() > aChecksumIndex ) &&
       
  1575         ( iPublishedDataStore[aChecksumIndex] == aItemChecksum ) )
       
  1576         {
       
  1577         // checksum match
       
  1578         return ETrue;
       
  1579         }
       
  1580     iPublishedDataStore.Reset();
       
  1581     return EFalse;
       
  1582     }
       
  1583 
       
  1584 // ======== GLOBAL FUNCTIONS ========
       
  1585 
       
  1586 // Return an instance of the proxy table.
       
  1587 
       
  1588 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
  1589     {
       
  1590     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
  1591     return ImplementationTable;
       
  1592     }
       
  1593 
       
  1594 // End of File