wvuing/wvuieng/EngSrc/Ccaengine.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This interface is used by UI to access network services i.e.
       
    15  *                sending messages and joining to groups e.g. This class is
       
    16  *                also used to get different interfaces to the services
       
    17  *                offered by the CCAEngine.dll.
       
    18  *
       
    19 */
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "ChatDebugPrint.h"
       
    24 
       
    25 #include "CCAEngine.h"
       
    26 
       
    27 #include "CCAChatContainer.h"
       
    28 #include "CCAMessageHandler.h"
       
    29 #include "CCAMessageCreator.h"
       
    30 
       
    31 #include "CCAContactListModel.h"
       
    32 #include "CCASearchManager.h"
       
    33 #include "MCASearchObserverInterface.h"
       
    34 #include "MCASearchData.h"
       
    35 #include "CCAGroupManager.h"
       
    36 #include "MCAGroupOperations.h"
       
    37 #include "CCABlockingManager.h"
       
    38 #include "CCAInviteManager.h"
       
    39 #include "CCAPartialSuccessData.h"
       
    40 #include "CCASettingsManager.h"
       
    41 #include "CCARequest.h"
       
    42 #include "CCARequestMapper.h"
       
    43 #include "MCAPresence.h"
       
    44 #include "PublicEngineDefinitions.h"
       
    45 #include "PrivateEngineDefinitions.h"
       
    46 #include "MCAStoredGroup.h"
       
    47 #include "MCAStoredGroups.h"
       
    48 #include "MCAExtendedStoredGroup.h"
       
    49 #include "CCAStorageManagerFactory.h"
       
    50 #include "CCAStorageObserver.h"
       
    51 
       
    52 #include "CAPresenceManager.h"
       
    53 #include "MCAPresence.h"
       
    54 
       
    55 #include "CCAAdapterDll.h"
       
    56 #include "MCAImpsFactory.h"
       
    57 #include "MCAImpsGroupClient.h"
       
    58 #include "MCAImpsImClient.h"
       
    59 #include "MCAImpsFundClient.h"
       
    60 #include "MCAError.h"
       
    61 #include "MCAStoredContacts.h"
       
    62 
       
    63 #include "CALoggerManagerFactory.h"
       
    64 #include "TCALoggerMessageFactory.h"
       
    65 #include "CCALoggerHeadersInterface.h"
       
    66 #include "CCAAccessManager.h"
       
    67 #include "CCAImageLoader.h"
       
    68 #include "MCAContentProcessor.h"
       
    69 
       
    70 #include "SServerPrefers.h"
       
    71 
       
    72 #include "ImpsCSPAllErrors.h"
       
    73 #include <e32base.h>
       
    74 
       
    75 // granularity used for small arrays, which usually
       
    76 // contains only one elements
       
    77 const TInt KSearchPairsSmallGranularity = 1;
       
    78 
       
    79 // maximum groups in search result. If search results
       
    80 // exceeds this then "too many search results" is shown
       
    81 const TInt KMaxGroupSearchLimit = 50;
       
    82 
       
    83 // ================= MEMBER FUNCTIONS =======================
       
    84 
       
    85 // Two-phased constructor.
       
    86 EXPORT_C CCAEngine* CCAEngine::NewL( TUid aAppUid )
       
    87     {
       
    88     CCAEngine* self = new ( ELeave ) CCAEngine( aAppUid );
       
    89 
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop( self );
       
    93 
       
    94     return self;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // CCAEngine::~CCAEngine()
       
    99 // Note the destruction order of objects.
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 EXPORT_C CCAEngine::~CCAEngine()
       
   103     {
       
   104     CHAT_DP_FUNC_ENTER( "~CCAEngine" );
       
   105 
       
   106     if ( iImpsImServer )
       
   107         {
       
   108         iImpsImServer->Unregister();
       
   109         }
       
   110 
       
   111     if ( iImpsGroupServer )
       
   112         {
       
   113         iImpsGroupServer->Unregister();
       
   114         }
       
   115 
       
   116     if ( iImpsFundAPI )
       
   117         {
       
   118         iImpsFundAPI->Unregister();
       
   119         }
       
   120 
       
   121     // Must be deleted before settings manager
       
   122     delete iContactListModel;
       
   123 
       
   124     delete iAccessManager;
       
   125     delete iGroupManager;
       
   126     delete iSearchManager;
       
   127     delete iBlockingManager;
       
   128     delete iInviteManager;
       
   129     delete iSettingsManager;
       
   130     delete iRequestMapper;
       
   131 
       
   132     delete iMessageHandler;
       
   133     delete iMessageCreator;
       
   134     delete iChatContainer;
       
   135 
       
   136     delete iImageLoader;
       
   137 
       
   138     delete iPartialSuccessData;
       
   139 
       
   140     // synch stuff. should be already deallocated but let's have a
       
   141     // failsafe delete here
       
   142     delete iLoggedUserId;
       
   143 
       
   144     // not reset done, because contains iRequest and don't want delete twice
       
   145     delete iPairs;
       
   146     delete iRequest;
       
   147     delete iStorageObserver;
       
   148 
       
   149     // Release singleton instances because we are sure,
       
   150     // that we do not need them anymore.
       
   151     TRAPD( ignore, CALoggerManagerFactory::ReleaseInstanceL() );
       
   152     TRAP( ignore, CCAStorageManagerFactory::ReleaseL() );
       
   153     TRAP( ignore, ReleaseAdapterL() );
       
   154     CAPresenceManager::Release();
       
   155 
       
   156     delete iLoggerMessageFactory;
       
   157     delete iLoggerHeadersInterface;
       
   158 
       
   159     CHAT_DP_FUNC_DONE( "~CCAEngine" );
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CCAEngine::GetInternalSettingsInterface()
       
   165 // ---------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CCAEngine::ResetLoggers()
       
   168     {
       
   169 #ifdef RD_MULTIPLE_DRIVE
       
   170     // Release singleton instances because we are sure,
       
   171     // that we do not need them anymore.
       
   172     TRAPD( ignore, CALoggerManagerFactory::ReleaseInstanceL() ;
       
   173 
       
   174            CHAT_DP( D_CHAT_LIT( " ignore %d" ), ignore );
       
   175            //Set message factory to logger    // now create these interfaces again...for newly changed drive....
       
   176 
       
   177            CALoggerManagerFactory::ReadInstanceL( iLoggerMessageFactory , EFalse ); );
       
   178 #endif
       
   179     }
       
   180 
       
   181 
       
   182 
       
   183 // ---------------------------------------------------------
       
   184 // CCAEngine::GetInternalSettingsInterface()
       
   185 // ---------------------------------------------------------
       
   186 //
       
   187 EXPORT_C MCASettings* CCAEngine::GetInternalSettingsInterface() const
       
   188     {
       
   189     return iSettingsManager;
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------
       
   193 // CCAEngine::GetSearchInterface()
       
   194 // ---------------------------------------------------------
       
   195 //
       
   196 EXPORT_C MCASearchInterface* CCAEngine::GetSearchInterface() const
       
   197     {
       
   198     return iSearchManager;
       
   199     }
       
   200 
       
   201 // ---------------------------------------------------------
       
   202 // CCAEngine::GetInviteInterface()
       
   203 // ---------------------------------------------------------
       
   204 //
       
   205 EXPORT_C MCAInvite* CCAEngine::GetInvitationInterface() const
       
   206     {
       
   207     return iInviteManager;
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------
       
   211 // CCAEngine::GetBlockingInterface()
       
   212 // ---------------------------------------------------------
       
   213 //
       
   214 EXPORT_C MCABlocking* CCAEngine::GetBlockingInterface() const
       
   215     {
       
   216     return iBlockingManager;
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------
       
   220 // CCAEngine::GetFundClientInterface()
       
   221 // ---------------------------------------------------------
       
   222 //
       
   223 EXPORT_C MCAImpsFundClient* CCAEngine::GetFundClientInterface() const
       
   224     {
       
   225     return iImpsFundAPI;
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------
       
   229 // CCAEngine::GetAccessInterface()
       
   230 // ---------------------------------------------------------
       
   231 //
       
   232 EXPORT_C MCAAccessInterface* CCAEngine::GetAccessInterface() const
       
   233     {
       
   234     return iAccessManager;
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------
       
   238 // CCAEngine::ContactListModel()
       
   239 // ---------------------------------------------------------
       
   240 //
       
   241 EXPORT_C MCAContactListModel& CCAEngine::ContactListModel() const
       
   242     {
       
   243     return *iContactListModel;
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------
       
   247 // CCAEngine::ChatInterface()
       
   248 // ---------------------------------------------------------
       
   249 //
       
   250 EXPORT_C MCAChatInterface& CCAEngine::ChatInterface() const
       
   251     {
       
   252     return *iChatContainer;
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------
       
   256 // CCAEngine::Messageutils()
       
   257 // ---------------------------------------------------------
       
   258 //
       
   259 EXPORT_C const MCAMessageUtils& CCAEngine::MessageUtils() const
       
   260     {
       
   261     return *this;
       
   262     }
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CCAEngine::GetGroupInterface()
       
   266 // ---------------------------------------------------------
       
   267 //
       
   268 EXPORT_C MCAGroupManagerInterface* CCAEngine::GetGroupInterface() const
       
   269     {
       
   270     return iGroupManager;
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------
       
   274 // CCAEngine::BackgroundInterface()
       
   275 // ---------------------------------------------------------
       
   276 //
       
   277 EXPORT_C MCABackgroundInterface* CCAEngine::BackgroundInterface() const
       
   278     {
       
   279     return iRequestMapper;
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------
       
   283 // CCAEngine::HandleNetworkStateChangeL
       
   284 // ---------------------------------------------------------
       
   285 //
       
   286 EXPORT_C void CCAEngine::HandleNetworkStateChangeL(
       
   287     TNetworkState aState,
       
   288     TPEngWVCspServicesTree2* aServicesSupported,
       
   289     const SServerPrefers& aServerPrefers,
       
   290     CPEngNWSessionSlotID2* aSessionSlotID /* = NULL */ )
       
   291     {
       
   292     CHAT_DP_FUNC_ENTER( "HandleNetworkStateChangeL" );
       
   293     CHAT_DP( D_CHAT_LIT( " * old state %d, new state %d" ), iState, aState );
       
   294 
       
   295     if ( ! iFullyConstructed )
       
   296         {
       
   297         // user cancelled login before it had even started,
       
   298         // engine is constructed half-way. so get out.
       
   299         CHAT_DP_TXT( "  Engine not fully constructed, get out." );
       
   300         return;
       
   301         }
       
   302 
       
   303     if ( iState == aState )
       
   304         {
       
   305         // If new state is the same as previous, then do nothing
       
   306         CHAT_DP_TXT( "CCAEngine::HandleNetworkStateChangeL with same state as \
       
   307                 previously! -> ignoring..." );
       
   308         return;
       
   309         }
       
   310 
       
   311     if ( aState == ELoggedIn )
       
   312         {
       
   313         // logged in, reconstruct contact list model for new server (change sorting order)
       
   314         MCAContactListModel* model = iContactListModel;
       
   315         model->SetSort();
       
   316         }
       
   317 
       
   318     TNetworkState oldState = iState;
       
   319 
       
   320     if ( aState != EServerPrefers )
       
   321         {
       
   322         iState = aState;
       
   323         }
       
   324 
       
   325     if ( aServicesSupported && iSearchManager )
       
   326         {
       
   327         TBool searchSupported =
       
   328             aServicesSupported->iFundamentalFeat.FunctionSupported(
       
   329                 KPEngFFSearchFunction );
       
   330         iSearchManager->SetSearchSupported( searchSupported );
       
   331         }
       
   332 
       
   333     iMessageHandler->SetLocalEchoInGroup( aServerPrefers.iLocalEchoInGroup );
       
   334 
       
   335     if ( aState != ESyncPresence && aState != EServerPrefers )
       
   336         {
       
   337         // ESyncPresence is a special case for presence manager only
       
   338 
       
   339         // notify RequestMapper
       
   340         if ( iRequestMapper )
       
   341             {
       
   342             iRequestMapper->HandleNetworkStateChange( aState );
       
   343             }
       
   344 
       
   345         // notify BlockingManager
       
   346         if ( iBlockingManager )
       
   347             {
       
   348             iBlockingManager->HandleNetworkStateChange(
       
   349                 aState, aServerPrefers.iUseGrant );
       
   350             }
       
   351 
       
   352         // notify GroupManager
       
   353         if ( iGroupManager )
       
   354             {
       
   355             iGroupManager->HandleNetworkStateChangeL( aState );
       
   356             }
       
   357 
       
   358         if ( aState == ELoggedIn )
       
   359             {
       
   360             SynchronizeGroupsL( aServicesSupported );
       
   361             }
       
   362         }
       
   363 
       
   364     // presence manager
       
   365     if ( iPresenceManager )
       
   366         {
       
   367         switch ( aState )
       
   368             {
       
   369             case ELoggedIn:
       
   370                 {
       
   371                 iPresenceManager->HandleNetworkStateL( MCAPresence::ELoggedIn,
       
   372                                                        aServerPrefers,
       
   373                                                        aSessionSlotID );
       
   374                 break;
       
   375                 }
       
   376 
       
   377             case ELoggingOut:
       
   378                 {
       
   379                 iPresenceManager->HandleNetworkStateL( MCAPresence::ELoggingOut,
       
   380                                                        aServerPrefers,
       
   381                                                        aSessionSlotID );
       
   382                 break;
       
   383                 }
       
   384 
       
   385             case ELoggedOut:
       
   386                 {
       
   387                 iPresenceManager->HandleNetworkStateL( MCAPresence::ELoggedOut,
       
   388                                                        aServerPrefers,
       
   389                                                        aSessionSlotID );
       
   390                 break;
       
   391                 }
       
   392             case EServerPrefers:
       
   393                 {
       
   394                 iPresenceManager->HandleNetworkStateL( MCAPresence::EUpdateBrand,
       
   395                                                        aServerPrefers,
       
   396                                                        aSessionSlotID );
       
   397                 return;
       
   398                 }
       
   399             case ESyncPresence:
       
   400                 {
       
   401                 CHAT_DP_TXT( "**ESyncPresence event**" );
       
   402                 if ( oldState != ELoggedIn )
       
   403                     {
       
   404                     CHAT_DP_TXT( "**Synchronizing presence settings**" );
       
   405                     // do not synchronize anything if we're logging out
       
   406                     iPresenceManager->SynchronizePresenceSettingsL(
       
   407                         aServerPrefers );
       
   408                     }
       
   409                 }
       
   410 
       
   411             default:
       
   412                 {
       
   413                 // Presence module does not support -> ignore
       
   414                 break;
       
   415                 }
       
   416             }
       
   417         }
       
   418 
       
   419     CHAT_DP_FUNC_DONE( "HandleNetworkStateChangeL" );
       
   420     }
       
   421 
       
   422 // ---------------------------------------------------------
       
   423 // CCAEngine::SynchronizeGroupsL()
       
   424 // ---------------------------------------------------------
       
   425 //
       
   426 void CCAEngine::SynchronizeGroupsL(
       
   427     TPEngWVCspServicesTree2* aServicesSupported )
       
   428     {
       
   429     CHAT_DP_FUNC_DP( "StartSyn", "Logging in" );
       
   430 
       
   431     TBool searchSupported = EFalse;
       
   432 
       
   433     // state changed to logged in
       
   434     if ( aServicesSupported )
       
   435         {
       
   436         searchSupported =
       
   437             aServicesSupported->iFundamentalFeat.FunctionSupported(
       
   438                 KPEngFFSearchFunction );
       
   439         iSearchManager->SetSearchSupported( searchSupported );
       
   440         CHAT_DP( D_CHAT_LIT( "CCAEngine::HandleNetworkStateChangeL \
       
   441                     - Search supported: %d" ), searchSupported );
       
   442         }
       
   443     else
       
   444         {
       
   445         CHAT_DP_FUNC_DP( "HandleNetworkStateChangeL",
       
   446                          "Services are not supported" );
       
   447         }
       
   448 
       
   449     // check if the groups are supported at all
       
   450 
       
   451     TBool groupsSupported = EFalse;
       
   452 
       
   453     if ( aServicesSupported )
       
   454         {
       
   455         // find out if the group stuff is supported
       
   456         groupsSupported = aServicesSupported->iGroupFeat.FeatureSupported();
       
   457         }
       
   458 
       
   459     if ( groupsSupported )
       
   460         {
       
   461         CHAT_DP_FUNC_DP( "SynchronizeGroupsL", "Groups are supported" );
       
   462 
       
   463         // groups are supported. search only if we can...
       
   464         if ( searchSupported )
       
   465             {
       
   466             // but make sure the search is not started yet
       
   467             if ( iRequestMapper->BackgroundTaskStatus(
       
   468                      MCABackgroundInterface::EGroupFetch ) &
       
   469                  ( MCABackgroundInterface::EUnknown |
       
   470                    MCABackgroundInterface::ECompleted |
       
   471                    MCABackgroundInterface::ECancelled |
       
   472                    MCABackgroundInterface::EFailed
       
   473                  ) )
       
   474                 {
       
   475                 CHAT_DP_FUNC_DP( "HandleNetworkStateChangeL",
       
   476                                  "Registering group list fetch" );
       
   477                 iRequestMapper->RegisterBackgroundTask( this,
       
   478                                                         MCABackgroundInterface::EGroupFetch );
       
   479                 }
       
   480             }
       
   481         else
       
   482             {
       
   483             CHAT_DP_FUNC_DP( "SynchronizeGroupsL", "Search is not supported" );
       
   484             // Search is not supported, so show all the groups the user has.
       
   485             // This is the only thing the IM Application can do about this
       
   486             // at the moment.
       
   487             iStoredGroups = CCAStorageManagerFactory::GroupListInterfaceL();
       
   488             iStoredGroups->ShowAllGroups();
       
   489             }
       
   490         }
       
   491     else
       
   492         {
       
   493         CHAT_DP_FUNC_DP( "SynchronizeGroupsL",
       
   494                          "Groups are not supported: hiding groups, \
       
   495                           not searching" );
       
   496 
       
   497         // groups are not supported
       
   498         // hide all our groups from storage
       
   499         iStoredGroups = CCAStorageManagerFactory::GroupListInterfaceL();
       
   500         iStoredGroups->HideAllGroups( ETrue );  // hides all groups
       
   501         }
       
   502     }
       
   503 
       
   504 // ---------------------------------------------------------
       
   505 // CCAEngine::PartialSuccessData()
       
   506 // ---------------------------------------------------------
       
   507 //
       
   508 EXPORT_C const RPointerArray<MCAError>* CCAEngine::PartialSuccessData() const
       
   509     {
       
   510     return iPartialSuccessData->PartialSuccessData();
       
   511     }
       
   512 
       
   513 // ---------------------------------------------------------
       
   514 // CCAEngine::HandleErrorL()
       
   515 // ---------------------------------------------------------
       
   516 //
       
   517 void CCAEngine::HandleErrorL(
       
   518     TInt           aStatus,
       
   519     TInt           aOpId,
       
   520     const TDesC*   aDescription,
       
   521     const CImpsDetailed* aDetailedRes,
       
   522     TImpsCspIdentifier& /*aCspId*/ )
       
   523     {
       
   524     CHAT_DP( D_CHAT_LIT( "CCAEngine::HandleErrorL, opid %d, status %d" ),
       
   525              aOpId, aStatus );
       
   526 
       
   527     if ( aDescription )
       
   528         {
       
   529         TPtrC descr( *aDescription );
       
   530         CHAT_DP( D_CHAT_LIT( "CCAEngine::HandleErrorL, description: %S" ),
       
   531                  &descr );
       
   532         }
       
   533 
       
   534     // In case of partial success store the data if it exists
       
   535     if ( ( aStatus == ECSPPartiallySuccessful ) && aDetailedRes )
       
   536         {
       
   537         CHAT_DP_TXT( "CCAEngine::HandleErrorL, \
       
   538                       partially successful situation.." );
       
   539         // must be trapped although this is an L-method because the request must
       
   540         // be handled in every case
       
   541         TRAPD( err,
       
   542                iPartialSuccessData->SetPartialSuccessDataL( *aDetailedRes ) );
       
   543         if ( err != KErrNone )
       
   544             {
       
   545             CActiveScheduler::Current()->Error( err );
       
   546             }
       
   547         }
       
   548 
       
   549     // in debug builds, print out the partial success data
       
   550 #ifdef _DEBUG
       
   551     const RPointerArray<MCAError>* myerrors =
       
   552         iPartialSuccessData->PartialSuccessData();
       
   553     if ( myerrors )
       
   554         {
       
   555         TInt limit( ( *myerrors ).Count() );
       
   556         for ( TInt i( 0 ); i < limit; i++ )
       
   557             {
       
   558             CHAT_DP( D_CHAT_LIT( "CCAEngine::HandleErrorL PSD code %d" ),
       
   559                      ( *myerrors )[i]->Code() );
       
   560             }
       
   561         }
       
   562 #endif
       
   563 
       
   564     // redirect the error code to appropriate manager
       
   565     TPtrC recipientPtr( KNullDesC );
       
   566 
       
   567     TInt error( KErrNotFound );
       
   568 
       
   569     if ( aOpId != 0 )
       
   570         {
       
   571         // This is not a push message, so try to find recipient
       
   572         recipientPtr.Set( iChatContainer->MessageRecipient( aOpId, error ) );
       
   573         }
       
   574 
       
   575     if ( ( error == KErrNotFound ) || ( recipientPtr.Length() == 0 ) )
       
   576         {
       
   577         // In this case the recipient doesn't exist which means that
       
   578         // this is not a sent message error
       
   579         // => redirect to requestmapper
       
   580 
       
   581         CHAT_DP_TXT( "CCAEngine::HandleErrorL, redirecting to RequestMapper" );
       
   582         iRequestMapper->HandleRequest( aOpId, aStatus );
       
   583         if ( aOpId == 0 )
       
   584             {//server pushed event
       
   585             iGroupManager->LastImpsError( aStatus );
       
   586             }
       
   587         }
       
   588     else
       
   589         {
       
   590         // We found a recipient for the message so this is a sent message error
       
   591         // => redirect to chatdatamanager
       
   592 
       
   593         const RPointerArray<MCAError>* partialData =
       
   594             iPartialSuccessData->PartialSuccessData();
       
   595 
       
   596         // If partially success data has error code ECSPRecipientBlockedSender
       
   597         // we can show the message as it was sent succesfully.
       
   598         TBool blockedSender( EFalse );
       
   599         if ( partialData )
       
   600             {
       
   601             if ( partialData->Count() == 1 ) // only one error code
       
   602                 {
       
   603                 if ( ( *partialData )[0]->Code() == ECSPRecipientBlockedSender )
       
   604                     {
       
   605                     blockedSender = ETrue;
       
   606                     }
       
   607                 }
       
   608             }
       
   609 
       
   610         if ( aStatus == ECSPPartiallySuccessful && blockedSender )
       
   611             {
       
   612             // In this case show that message sending was successful
       
   613             CHAT_DP_TXT( "CCAEngine::HandleErrorL, ECSPRecipientBlockedSender, \
       
   614                     redirecting to ChatDataManager" );
       
   615             iMessageHandler->HandleMessageSentL( KErrNone, aOpId, ETrue );
       
   616             }
       
   617         else
       
   618             {
       
   619             // Message sending was not successful,
       
   620             // "IM.Recipient.Blocked.Messages" functionality
       
   621             CHAT_DP_TXT( "CCAEngine::HandleErrorL, other error, redirecting to \
       
   622                     ChatDataManager" );
       
   623             CHAT_DP( D_CHAT_LIT( "CCAEngine::HandleErrorL, indicating error, \
       
   624                         recipient: %S" ), &recipientPtr );
       
   625             iMessageHandler->HandleMessageSentL( aStatus, aOpId, EFalse );
       
   626             }
       
   627         }
       
   628     }
       
   629 
       
   630 // ---------------------------------------------------------
       
   631 // CCAEngine::HandleSettingsChangeL()
       
   632 // ---------------------------------------------------------
       
   633 //
       
   634 void CCAEngine::HandleSettingsChangeL( TInt aChangedSettingEnum )
       
   635     {
       
   636     CHAT_DP_TXT( "CCAEngine::HandleSettingsChange" );
       
   637 
       
   638     if ( iPresenceManager )
       
   639         {
       
   640         iPresenceManager->HandleSettingsChangeL( aChangedSettingEnum );
       
   641         }
       
   642     }
       
   643 
       
   644 // Symbian OS default constructor can leave.
       
   645 void CCAEngine::ConstructL()
       
   646     {
       
   647     // Construct request mapper
       
   648     iRequestMapper = CCARequestMapper::NewL();
       
   649 
       
   650     // Setting engine to listen errors in group fetching in background task
       
   651     iRequestMapper->RegisterBackgroundObserver(
       
   652         this,
       
   653         MCABackgroundInterface::EGroupFetch,
       
   654         MCABackgroundInterface::EFailed );
       
   655 
       
   656     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCARequestMapper" );
       
   657 
       
   658     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCASettingsManager" );
       
   659 
       
   660     // Create manager for internal settings handling
       
   661     iSettingsManager = CCASettingsManager::NewL( iAppUid );
       
   662     iSettingsManager->AddObserverL( this );
       
   663 
       
   664     CHAT_DP_TXT( "CCAEngine::ConstructL, creating iChatContainer" );
       
   665 
       
   666     iContactListModel = CCAContactListModel::NewL( *iSettingsManager );
       
   667     CHAT_DP( D_CHAT_LIT( "iContactListModel constructed..." ) );
       
   668 
       
   669     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCAPresenceManager" );
       
   670     // it's a singleton and always present
       
   671     iPresenceManager = CAPresenceManager::InstanceL( iSettingsManager );
       
   672 
       
   673     CHAT_DP( D_CHAT_LIT( "iPresenceManager constructed..." ) );
       
   674 
       
   675     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCAMessageCreator" );
       
   676 
       
   677     iMessageCreator = CCAMessageCreator::NewL();
       
   678 
       
   679     CHAT_DP( D_CHAT_LIT( "CCAMessageCreator constructed..." ) );
       
   680 
       
   681     // Construct the partial success data holder also
       
   682     iPartialSuccessData = CCAPartialSuccessData::NewL();
       
   683 
       
   684     //This T-class is heap-allocated only because we do not want to
       
   685     //include T-class header in header file of CCAEngine.
       
   686     iLoggerMessageFactory = new ( ELeave ) TCALoggerMessageFactory;
       
   687 
       
   688     //Set message factory to logger
       
   689     CALoggerManagerFactory::ReadInstanceL( iLoggerMessageFactory );
       
   690 
       
   691     CHAT_DP_TXT( "CCAEngine::ConstructL, done." );
       
   692     iGroupSynchronizing = EFalse;
       
   693     }
       
   694 
       
   695 EXPORT_C TBool CCAEngine::ReadyForShutdown()
       
   696     {
       
   697     if ( iRequestMapper )
       
   698         {
       
   699         if ( iRequestMapper->WaitCount() )
       
   700             {
       
   701             return EFalse;
       
   702             }
       
   703         }
       
   704     return ETrue;
       
   705     }
       
   706 
       
   707 EXPORT_C void CCAEngine::CancelAllRequests()
       
   708     {
       
   709     if ( iRequestMapper )
       
   710         {
       
   711         iRequestMapper->CancelAllRequests();
       
   712         }
       
   713 
       
   714     if ( iPresenceManager )
       
   715         {
       
   716         iPresenceManager->CancelPendingRequests();
       
   717         }
       
   718     }
       
   719 
       
   720 EXPORT_C MCALoggerHeadersInterface* CCAEngine::GetLoggerHeadersInterface()
       
   721     {
       
   722     return iLoggerHeadersInterface;
       
   723     }
       
   724 
       
   725 // stop synchronizing the groups
       
   726 void CCAEngine::StopSynchronizeGroupsL()
       
   727     {
       
   728     CHAT_DP_FUNC_ENTER( "StopSynchronizeGroupsL" );
       
   729 
       
   730     if ( ! iGroupSynchronizing )
       
   731         {
       
   732         // don't bother, group synchronizing already stopped
       
   733         // or not yet started
       
   734         return;
       
   735         }
       
   736 
       
   737     // Make sure that our state will be right one.
       
   738     // Sync should be over after this method.
       
   739 
       
   740     CHAT_DP_FUNC_DP( "StopSynchronizeGroupsL", "Ending search" );
       
   741     TInt status = KErrNone;
       
   742     TRAPD( err, status = iSearchManager->EndSearchL() );
       
   743 
       
   744     iGroupSynchronizing = EFalse;
       
   745 
       
   746     User::LeaveIfError( err );
       
   747 
       
   748     // Ignore the cancel error code. We don't want to show
       
   749     // error note when exiting the application while search was
       
   750     // active
       
   751     if ( status != EOperationCancelled )
       
   752         {
       
   753         User::LeaveIfError( status );
       
   754         }
       
   755 
       
   756     CHAT_DP_FUNC_DP( "StopSynchronizeGroupsL", "Deallocating stuff" );
       
   757 
       
   758     // make sure we're done
       
   759     if ( iLoggedUserId )
       
   760         {
       
   761         delete iLoggedUserId;
       
   762         iLoggedUserId = NULL;
       
   763         }
       
   764 
       
   765     if ( iPairs )
       
   766         {
       
   767         // not reset done, because contains iRequest
       
   768         // and don't want delete twice
       
   769         delete iPairs;
       
   770         iPairs = NULL;
       
   771         }
       
   772 
       
   773     if ( iRequest )
       
   774         {
       
   775         delete iRequest;
       
   776         iRequest = NULL;
       
   777         }
       
   778 
       
   779     iSearchResults = NULL;
       
   780 
       
   781     CHAT_DP_FUNC_DONE( "StopSynchronizeGroupsL" );
       
   782     }
       
   783 
       
   784 // synchronize the groups in storage with those in the server
       
   785 void CCAEngine::StartSynchronizeGroupsL()
       
   786     {
       
   787     CHAT_DP_FUNC_ENTER( "StartSynchronizeGroupsL" );
       
   788 
       
   789     // make sure we're stopped
       
   790     StopSynchronizeGroupsL();
       
   791 
       
   792     if ( ! iStoredGroups )
       
   793         {
       
   794         // lazy initialization
       
   795         iStoredGroups = CCAStorageManagerFactory::GroupListInterfaceL();
       
   796         }
       
   797 
       
   798     // make all groups invisible
       
   799     iStoredGroups->HideAllGroups();
       
   800 
       
   801     delete iLoggedUserId;
       
   802     iLoggedUserId = NULL;
       
   803     iLoggedUserId = iSettingsManager->ValueL( MCASettings::EOwnWVUserID );
       
   804 
       
   805     CSearchPairs* tempPairs =
       
   806         new ( ELeave ) CSearchPairs( KSearchPairsSmallGranularity );
       
   807     CleanupStack::PushL( tempPairs );
       
   808     CImpsSearchRequest* tempRequest = CImpsSearchRequest::NewL();
       
   809     CleanupStack::PushL( tempRequest );
       
   810     tempRequest->SetRequestL( EImpsGroupUserIDOwner, *iLoggedUserId );
       
   811     tempPairs->AppendL( tempRequest );
       
   812     CleanupStack::Pop( tempRequest );
       
   813     CleanupStack::Pop( tempPairs );
       
   814     delete iPairs;
       
   815     delete iRequest;
       
   816     iPairs = tempPairs;
       
   817     iRequest = tempRequest;
       
   818 
       
   819     // If there is error in search, return so we don't send stop error request
       
   820     TInt searchError( KErrNone );
       
   821     TInt err( KErrNone );
       
   822     TRAP( err, searchError =
       
   823               iSearchManager->StartSearchL( *iPairs, KMaxGroupSearchLimit, this ) );
       
   824 
       
   825     iGroupSynchronizing = ETrue;
       
   826 
       
   827     // it's synchronous
       
   828     if ( ( err != KErrNone ) || ( searchError != KErrNone ) )
       
   829         {
       
   830         // we must cleanup so we can't just leave
       
   831         CHAT_DP( D_CHAT_LIT( "CCAEngine::StartSynchronizeGroupsL - error from \
       
   832                               StartSearchL %d, err %d" ), searchError, err );
       
   833         StopSynchronizeGroupsL();
       
   834 
       
   835         // leave now, when it's all clean and tidy
       
   836         // Leave also with cancel --> but leave quietly
       
   837         if ( KErrNone == searchError || EOperationCancelled == searchError )
       
   838             {
       
   839             User::Leave( err );
       
   840             }
       
   841         else
       
   842             {
       
   843             User::Leave( searchError );
       
   844             }
       
   845         }
       
   846 
       
   847     DoHandleSearchFinishedL();
       
   848     StopSynchronizeGroupsL();
       
   849 
       
   850     CHAT_DP_FUNC_DONE( "StartSynchronizeGroupsL" );
       
   851     }
       
   852 
       
   853 // from MCASearchObserverInterface
       
   854 void CCAEngine::HandleSearchError( TInt /* aErrorCode */ )
       
   855     {
       
   856     CHAT_DP_FUNC_ENTER( "HandleSearchError" );
       
   857 
       
   858     // something bad happened
       
   859     TRAPD( err, StopSynchronizeGroupsL() );
       
   860     if ( err != KErrNone )
       
   861         {
       
   862         CHAT_DP( D_CHAT_LIT( "CCAEngine::HandleSearchError - Unexpected, \
       
   863                               left with %d" ), err );
       
   864         CActiveScheduler::Current()->Error( err );
       
   865         }
       
   866 
       
   867     CHAT_DP_FUNC_DONE( "HandleSearchError" );
       
   868     }
       
   869 
       
   870 // the actual leaving handler for finished searches
       
   871 void CCAEngine::DoHandleSearchFinishedL()
       
   872     {
       
   873     CHAT_DP_FUNC_ENTER( "DoHandleSearchFinishedL" );
       
   874 
       
   875     TInt resultCount(
       
   876         iSearchManager->SearchDataInterface()->SearchDataCount() );
       
   877 
       
   878     CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - found %d \
       
   879                           groups from joined user" ), resultCount );
       
   880     CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - From index \
       
   881                           %d to %d" ), iSearchResults, resultCount - 1 );
       
   882     TInt status = KErrNone;
       
   883     for ( TInt counter( iSearchResults ); counter < resultCount; counter++ )
       
   884         {
       
   885         // handle requests, but don't handle the groups which were already there
       
   886         if ( status == EOperationCancelled )
       
   887             {
       
   888             CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - \
       
   889                                   Operation Cancelled" ) );
       
   890             break;
       
   891             }
       
   892 
       
   893         // see if this group is already in storage
       
   894         TPtrC groupId( iSearchManager->SearchDataInterface()->SearchData(
       
   895                            counter ) );
       
   896         MCAStoredGroup* group = iStoredGroups->FindGroup( groupId );
       
   897 
       
   898         if ( !group )
       
   899             {
       
   900             CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - Group\
       
   901                                   %S is not in storage, adding" ), &groupId );
       
   902 
       
   903             // not found
       
   904             // so create group to storage with valid parameters:
       
   905             // must have groupid (before group operations), groupname, owngroup
       
   906 
       
   907             MCAExtendedStoredGroup* exGrp = iStoredGroups->CreateGroupL();  // CSI: 35 # Ownership is not transferred to caller.
       
   908             exGrp->SetGroupIdL( groupId );
       
   909             // make it invisible
       
   910             exGrp->SetVisible( EFalse );
       
   911             MCAGroupOperations* grOp =
       
   912                 iGroupManager->GroupOperationsL( groupId );
       
   913 
       
   914             CImpsCommonGroupProps* commonProps = NULL;
       
   915             CImpsPrivateGroupProps* privProps = NULL;
       
   916 
       
   917             // fetch properties from network
       
   918             CHAT_DP_FUNC_DP( "DoHandleSearchFinishedL", "Getting properties" );
       
   919             status = grOp->GetPropertiesL( commonProps, privProps ) ;
       
   920             if ( status == EOperationCancelled )
       
   921                 {
       
   922                 CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - \
       
   923 	                                  Operation Cancelled" ) );
       
   924                 break;
       
   925                 }
       
   926             if ( commonProps )
       
   927                 {
       
   928                 // group name has to be known
       
   929                 TPtrC name( commonProps->GroupName() );
       
   930                 CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - \
       
   931                                       Group has name '%S'" ), &name );
       
   932                 if ( name.Length() > 0 )
       
   933                     {
       
   934                     exGrp->SetGroupNameL( name );
       
   935                     }
       
   936                 else
       
   937                     {
       
   938                     exGrp->SetGroupNameL( KNullDesC );
       
   939                     }
       
   940 
       
   941                 // our very own group
       
   942                 exGrp->SetOwnGroup( ETrue );
       
   943 
       
   944                 // make it visible
       
   945                 exGrp->SetVisible( ETrue );
       
   946 
       
   947                 // save the group and signal the UI the group changed
       
   948                 iStoredGroups->SaveGroupL( groupId );
       
   949                 }
       
   950             else
       
   951                 {
       
   952                 CHAT_DP_FUNC_DP( "DoHandleSearchFinishedL",
       
   953                                  "No common properties" );
       
   954                 // if the name can't be fetched,
       
   955                 // name the group with group's wvid
       
   956                 exGrp->SetGroupNameL( groupId );
       
   957                 }
       
   958 
       
   959             }
       
   960         else
       
   961             {
       
   962             CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - \
       
   963                 Group %S is already in storage, making it visible" ), &groupId );
       
   964             ( static_cast<MCAExtendedStoredGroup *>( group ) )->SetVisible( ETrue );
       
   965             iStoredGroups->SignalGroupAddedL( groupId );
       
   966             }
       
   967         }
       
   968 
       
   969     // add only number of new ones
       
   970     iSearchResults += ( resultCount - iSearchResults );
       
   971     CHAT_DP( D_CHAT_LIT( "CCAEngine::DoHandleSearchFinishedL - Searching, index \
       
   972                           is now %d" ), iSearchResults );
       
   973 
       
   974     CHAT_DP_FUNC_DONE( "DoHandleSearchFinishedL" );
       
   975     }
       
   976 
       
   977 // from MCASearchObserverInterface
       
   978 void CCAEngine::HandleSearchFinished( )
       
   979     {
       
   980     CHAT_DP_FUNC_ENTER( "HandleSearchFinished" );
       
   981 
       
   982     CHAT_DP_FUNC_DONE( "HandleSearchFinished" );
       
   983     }
       
   984 
       
   985 // from MCABackgroundTask
       
   986 void CCAEngine::HandleBackgroundTaskL( TInt aSubTask )
       
   987     {
       
   988     CHAT_DP_FUNC_ENTER( "HandleBackgroundTaskL" );
       
   989     CHAT_DP( D_CHAT_LIT( "CCABlockingManager::HandleBackgroundTaskL Subtask \
       
   990 	                      is: %d" ), aSubTask );
       
   991 
       
   992     StartSynchronizeGroupsL();
       
   993 
       
   994     // imps errors are ignored at the moment as we don't have any
       
   995     // notes specified for them
       
   996 
       
   997     CHAT_DP_FUNC_DONE( "HandleBackgroundTaskL" );
       
   998     }
       
   999 
       
  1000 // from MCABackgroundObserver
       
  1001 void CCAEngine::HandleBackgroundEvent(
       
  1002     MCABackgroundInterface::TCABackgroundTasks aEventSource,
       
  1003     MCABackgroundInterface::TCABackgroundStatus aStatus,
       
  1004     TInt /*aSubTaskNumber*/,
       
  1005     TInt aLeaveCode )
       
  1006     {
       
  1007     // Currently we are interested only group fetching problems
       
  1008     if ( ( aEventSource == MCABackgroundInterface::EGroupFetch ) &&
       
  1009          ( aStatus == MCABackgroundInterface::EFailed ) )
       
  1010         {
       
  1011         if ( ( aLeaveCode > Imps_ERROR_BASE ) && ( aLeaveCode < KErrNone ) )
       
  1012             {
       
  1013             // propagate system errors to current active scheduler,
       
  1014             // it should show a note
       
  1015             CActiveScheduler::Current()->Error( aLeaveCode );
       
  1016             }
       
  1017         // imps errors are ignored at the moment as we don't have any
       
  1018         // notes specified for them
       
  1019         }
       
  1020     }
       
  1021 
       
  1022 
       
  1023 // ---------------------------------------------------------
       
  1024 // CCAEngine::MessageCreator()
       
  1025 // ---------------------------------------------------------
       
  1026 //
       
  1027 MCAMessageCreator& CCAEngine::MessageCreator() const
       
  1028     {
       
  1029     return *iMessageCreator;
       
  1030     }
       
  1031 
       
  1032 // ---------------------------------------------------------
       
  1033 // CCAEngine::MessageErrorInformer()
       
  1034 // ---------------------------------------------------------
       
  1035 //
       
  1036 MCAMessageErrorInformer& CCAEngine::MessageErrorInformer() const
       
  1037     {
       
  1038     return *iMessageHandler;
       
  1039     }
       
  1040 
       
  1041 // ---------------------------------------------------------
       
  1042 // CCAEngine::ImageScaler()
       
  1043 // ---------------------------------------------------------
       
  1044 //
       
  1045 MCAContentProcessor& CCAEngine::ImageScaler() const
       
  1046     {
       
  1047     return *iImageLoader;
       
  1048     }
       
  1049 
       
  1050 // ---------------------------------------------------------
       
  1051 // CCAEngine::MemoryHandler
       
  1052 // ---------------------------------------------------------
       
  1053 //
       
  1054 MCABufferMemoryHandler& CCAEngine::MemoryHandler() const
       
  1055     {
       
  1056     return *iChatContainer;
       
  1057     }
       
  1058 
       
  1059 
       
  1060 // C++ default constructor can NOT contain any code, that
       
  1061 // might leave.
       
  1062 //
       
  1063 CCAEngine::CCAEngine( TUid aAppUid )
       
  1064         :   iAppUid( aAppUid ),
       
  1065         iState( ELoggedOut )
       
  1066     {
       
  1067     }
       
  1068 
       
  1069 // ---------------------------------------------------------
       
  1070 // CCAEngine::FinalizeEngineConstructionL()
       
  1071 // ---------------------------------------------------------
       
  1072 //
       
  1073 EXPORT_C void CCAEngine::FinalizeEngineConstructionL()
       
  1074     {
       
  1075     CHAT_DP_FUNC_ENTER( "FinalizeEngineConstructionL" );
       
  1076 
       
  1077     if ( iFullyConstructed )
       
  1078         {
       
  1079         // nothing to do
       
  1080         CHAT_DP_TXT( "  Already fully constructed, all done" );
       
  1081         CHAT_DP_FUNC_DONE( "FinalizeEngineConstructionL" );
       
  1082         return;
       
  1083         }
       
  1084 
       
  1085     MCAImpsFactory* impsFactory = CreateImpsFactoryL();
       
  1086 
       
  1087     CHAT_DP_TXT( "CCAEngine::ConstructL, CCAAccessManager::NewL" );
       
  1088     iAccessManager = CCAAccessManager::NewL( *iRequestMapper );
       
  1089 
       
  1090     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCASearchManager for searching \
       
  1091             and synchronizing groups" );
       
  1092     iSearchManager = CCASearchManager::NewL( impsFactory, iRequestMapper );
       
  1093 
       
  1094     iChatContainer = CCAChatContainer::NewL( *iSettingsManager );
       
  1095     CHAT_DP( D_CHAT_LIT( "iChatContainer constructed..." ) );
       
  1096 
       
  1097     iImageLoader = CCAImageLoader::NewL( *iChatContainer, *impsFactory );
       
  1098     CHAT_DP( D_CHAT_LIT( "iImageLoader constructed..." ) );
       
  1099 
       
  1100     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCAGroupManager" );
       
  1101     iGroupManager = CCAGroupManager::NewL( *iSearchManager,
       
  1102                                            *iSettingsManager, *iRequestMapper, impsFactory,
       
  1103                                            *iChatContainer, *this );
       
  1104 
       
  1105     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCABlockingManager" );
       
  1106 
       
  1107     iBlockingManager = CCABlockingManager::NewL(
       
  1108                            impsFactory,
       
  1109                            iRequestMapper,
       
  1110                            iSettingsManager );
       
  1111 
       
  1112     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCAMessageHandler" );
       
  1113 
       
  1114     iMessageHandler = CCAMessageHandler::NewL( *iChatContainer, *this,
       
  1115                                                impsFactory );
       
  1116 
       
  1117     CHAT_DP( D_CHAT_LIT( "CCAMessageHandler constructed..." ) );
       
  1118 
       
  1119     iSettingsManager->AddObserverL( iBlockingManager );
       
  1120 
       
  1121     CHAT_DP_TXT( "CCAEngine::ConstructL, creating CCAInviteManager" );
       
  1122 
       
  1123     iInviteManager = CCAInviteManager::NewL( impsFactory,
       
  1124                                              *iSettingsManager,
       
  1125                                              *iRequestMapper,
       
  1126                                              *iGroupManager );
       
  1127 
       
  1128     CHAT_DP_TXT( "CCAEngine::ConstructL, registering APIs" );
       
  1129 
       
  1130     // Register observers and error handlers
       
  1131     CHAT_DP_TXT( "CCAEngine::ConstructL, CreateFundClientL" );
       
  1132     iImpsFundAPI = impsFactory->CreateFundClientL();
       
  1133     iImpsFundAPI->RegisterL( iSearchManager, iInviteManager );
       
  1134     iImpsFundAPI->RegisterErrorObserverL( *this );
       
  1135 
       
  1136     CHAT_DP_TXT( "CCAEngine::ConstructL, CreateImClientL" );
       
  1137     iImpsImServer = impsFactory->CreateImClientL();
       
  1138     iImpsImServer->RegisterL( iMessageHandler, iBlockingManager, iAppUid,
       
  1139                               CActive::EPriorityIdle );
       
  1140     iImpsImServer->RegisterErrorObserverL( *this );
       
  1141 
       
  1142     CHAT_DP_TXT( "CCAEngine::ConstructL, CreateGroupClientL" );
       
  1143     iImpsGroupServer = impsFactory->CreateGroupClientL();
       
  1144 
       
  1145     iImpsGroupServer->RegisterL( iGroupManager, iAppUid,
       
  1146                                  CActive::EPriorityIdle );
       
  1147     iImpsGroupServer->RegisterErrorObserverL( *this );
       
  1148 
       
  1149     iStorageObserver = CCAStorageObserver::NewL(
       
  1150                            *iSettingsManager,
       
  1151                            *CCAStorageManagerFactory::ContactListInterfaceL(),
       
  1152                            *iPresenceManager,
       
  1153                            *iBlockingManager );
       
  1154 
       
  1155     //Create interface for access to history headers
       
  1156     iLoggerHeadersInterface =
       
  1157         CCALoggerHeadersInterface::NewL( *iChatContainer, iSettingsManager );
       
  1158 
       
  1159     // whip up the IMPS server
       
  1160     impsFactory->ConnectL();
       
  1161 
       
  1162     iFullyConstructed = ETrue;
       
  1163 
       
  1164     CHAT_DP_FUNC_DONE( "FinalizeEngineConstructionL" );
       
  1165     }
       
  1166 
       
  1167 // ---------------------------------------------------------
       
  1168 // CCAEngine::IsEngineFinalized()
       
  1169 // ---------------------------------------------------------
       
  1170 //
       
  1171 EXPORT_C TBool CCAEngine::IsFinalized()
       
  1172     {
       
  1173     return iFullyConstructed;
       
  1174     }
       
  1175 
       
  1176 // ---------------------------------------------------------
       
  1177 // CCAEngine::IsBackgroundTaskPending()
       
  1178 // ---------------------------------------------------------
       
  1179 
       
  1180 EXPORT_C TBool CCAEngine::IsBackgroundTaskPending()
       
  1181     {
       
  1182     return iRequestMapper->IsBackgroundTaskPending();
       
  1183     }
       
  1184 
       
  1185 // ---------------------------------------------------------
       
  1186 // CCAEngine::RegisterBackGroundTaskObserver()
       
  1187 // ---------------------------------------------------------
       
  1188 //
       
  1189 EXPORT_C void CCAEngine::RegisterBackGroundTaskObserver( MCABackGroundTaskObserver* aObserver )
       
  1190     {
       
  1191     iRequestMapper->RegisterBackGroundTaskObserver( aObserver );
       
  1192     }
       
  1193 
       
  1194 // ---------------------------------------------------------
       
  1195 // CCAEngine::UnRegisterBackGroundTaskObserver()
       
  1196 // ---------------------------------------------------------
       
  1197 //
       
  1198 EXPORT_C void CCAEngine::UnRegisterBackGroundTaskObserver( MCABackGroundTaskObserver* aObserver )
       
  1199     {
       
  1200     iRequestMapper->UnRegisterBackGroundTaskObserver( aObserver );
       
  1201     }
       
  1202 
       
  1203 
       
  1204 
       
  1205 //  End of File