mediator/src/Server/MediatorServerEventHandler.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 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:  Event handling logic for the Mediator Server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <e32base.h>
       
    21 
       
    22 #include    "MediatorServerEventHandler.h"
       
    23 #include    "MediatorServerObjects.h"
       
    24 #include    "MediatorServiceDefs.h"
       
    25 #include    "Debug.h"
       
    26 
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CMediatorServerEventHandler::CMediatorServerEventHandler
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CMediatorServerEventHandler::CMediatorServerEventHandler( 
       
    35             CMediatorServerObjectHandler& aObjectHandler )
       
    36     : CActive( EPriorityStandard ), iObjectHandler( aObjectHandler )         
       
    37     {
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CMediatorServerEventHandler::ConstructL
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CMediatorServerEventHandler::ConstructL()
       
    45     {
       
    46     CActiveScheduler::Add( this );
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CMediatorServerEventHandler::NewL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CMediatorServerEventHandler* CMediatorServerEventHandler::NewL(
       
    54             CMediatorServerObjectHandler& aObjectHandler )
       
    55     {
       
    56     LOG(_L("[Mediator Server]\t CMediatorServerEventHandler::NewL"));
       
    57     CMediatorServerEventHandler* self 
       
    58             = new( ELeave ) CMediatorServerEventHandler( aObjectHandler );
       
    59     
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop( self );
       
    63 
       
    64     return self;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CMediatorServerEventHandler::~CMediatorServerEventHandler
       
    69 // -----------------------------------------------------------------------------
       
    70 //    
       
    71 CMediatorServerEventHandler::~CMediatorServerEventHandler()
       
    72     {
       
    73     Cancel();
       
    74     // Clear event list
       
    75     iEventServiceList.ResetAndDestroy();
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CMediatorServerEventHandler::DoCancel
       
    80 //  
       
    81 // (other items were commented in a header).
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CMediatorServerEventHandler::DoCancel()
       
    85     {
       
    86     TRACE(Print(_L("[Mediator Server]\t CMediatorServerEventHandler::DoCancel\n")));  
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CMediatorServerEventHandler::RunL
       
    91 //  
       
    92 // (other items were commented in a header).
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CMediatorServerEventHandler::RunL()
       
    96     {
       
    97     TRACE(Print(_L("[Mediator Server]\t CMediatorServerEventHandler::RunL status %d\n"), iStatus.Int() ));  
       
    98     
       
    99     // Should be no errors unless cancel
       
   100     if ( iStatus == KErrNone )
       
   101         {
       
   102         if ( iEventServiceList.Count() > 0 )
       
   103             {
       
   104             CEvent* serviceEvent = iEventServiceList[0];    // Take the first
       
   105             iEventServiceList.Remove(0); // remove event from array
       
   106             if ( serviceEvent )
       
   107                 {
       
   108                 // Get event information
       
   109                 TUid domain = serviceEvent->Domain();
       
   110                 TUid category = serviceEvent->Category();
       
   111                 TInt eventId = serviceEvent->Id();
       
   112                 const TDesC8& data = serviceEvent->ParameterData();
       
   113                 
       
   114                 RPointerArray<MMediatorServerEventObserver>& observers
       
   115                     = serviceEvent->GetObservers();
       
   116                 
       
   117                 // Loop through the observer array and send notifications
       
   118                 for ( TInt index = 0; index < observers.Count(); index++ )
       
   119                     {
       
   120                     MMediatorServerEventObserver* observer = observers[index]; 
       
   121                     if ( observer )
       
   122                         {
       
   123                         TRAP_IGNORE( observer->MediatorEventL( domain,
       
   124                                                                category,
       
   125                                                                eventId,
       
   126                                                                data ) );
       
   127                         }
       
   128                     }
       
   129                 delete serviceEvent;
       
   130                 }
       
   131             // Continue if there's still more to serve
       
   132             if ( iEventServiceList.Count() > 0 )
       
   133                 {
       
   134                 SetActive();
       
   135                 iStatus = KRequestPending;
       
   136                 TRequestStatus* stat = &iStatus;
       
   137                 User::RequestComplete( stat, KErrNone );
       
   138                 }
       
   139             }
       
   140         }
       
   141     LOG(_L("[Mediator Server]\t CMediatorServerEventHandler::RunL end"));
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CMediatorServerEventHandler::RegisterEventListL
       
   146 //  
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CMediatorServerEventHandler::RegisterEventListL( 
       
   151                 TMediatorCategory aCategory, 
       
   152                 const REventList& aEvents,
       
   153                 TSecureId aSecureId )
       
   154     {
       
   155     LOG(_L("[Mediator Server]\t CMediatorServerEventHandler::RegisterEventListL"));
       
   156     // Check that domain exists --> if not add new
       
   157     CDomain* domain = iObjectHandler.FindDomain( aCategory.iDomain );
       
   158     if ( !domain )
       
   159         {
       
   160         domain = iObjectHandler.AddDomainL( aCategory.iDomain );
       
   161         }
       
   162     
       
   163     // Check that category exists --> if not add new
       
   164     TInt ignore = 0; // not used here    
       
   165     CCategory* category = domain->FindCategory( aCategory.iCategory, ignore );
       
   166     if ( !category )
       
   167         {
       
   168         category = domain->AddCategoryL( aCategory.iCategory );
       
   169         }
       
   170     
       
   171     // Loop through the events and add them to list
       
   172     // Take the possible error to variable
       
   173     TInt error = KErrNone;
       
   174     TBool stop = EFalse;
       
   175     TInt index = 0;
       
   176     for ( index = 0; index < aEvents.Count() && !stop; index++ )
       
   177         {
       
   178         CEvent* newEvent = CEvent::NewL( aEvents[index] );
       
   179         CleanupStack::PushL( newEvent );
       
   180         newEvent->SetSecureId( aSecureId );
       
   181         newEvent->SetCommitState( CItem::EAdded );
       
   182         TInt addError = category->AddEvent( newEvent );
       
   183         if ( addError )
       
   184             {
       
   185             ERROR_TRACE(Print(_L("[Mediator] CMediatorServerEventHandler::RegisterEventListL: addError=%d\n"), addError ) );
       
   186             ERROR_TRACE(Print(_L("[Mediator] Failed to add event %d to category %d of domain %d\n"), newEvent->Id(), 
       
   187                                                                                                      aCategory.iCategory.iUid,
       
   188                                                                                                      aCategory.iDomain.iUid ) );
       
   189             // in case of error, delete event and take error
       
   190             CleanupStack::PopAndDestroy( newEvent );
       
   191             error = addError;
       
   192             stop = ETrue;
       
   193             }
       
   194         else
       
   195             {
       
   196             // Event has been added properly --> just pop
       
   197             CleanupStack::Pop( newEvent );
       
   198             }     
       
   199         }  
       
   200     
       
   201     TRACE(Print(_L("[Mediator Server]\t Events registered:\n")));
       
   202     TRACE(Print(_L("[Mediator Server]\t Success/count: %d/%d \tstatus: %d"), index, aEvents.Count(), error ));    
       
   203     // Check error if we need to do partial recovery
       
   204     if ( error != KErrNone  ) 
       
   205         {
       
   206         // Remove events that already have been added
       
   207         category->RollbackEvents();
       
   208         }
       
   209     else
       
   210         {
       
   211         // Complete event list update
       
   212         category->CommitEvents();
       
   213         
       
   214         // Use the object handler to notify events
       
   215         iObjectHandler.EventsAdded( aCategory.iDomain, 
       
   216                                     aCategory.iCategory, 
       
   217                                     aEvents );
       
   218         }
       
   219     // In the end leave if error --> client gets error code
       
   220     User::LeaveIfError( error );
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CMediatorServerEventHandler::UnregisterEventListL
       
   225 //  
       
   226 // (other items were commented in a header).
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void CMediatorServerEventHandler::UnregisterEventListL( TMediatorCategory aCategory, 
       
   230                                                         const REventList& aEvents,
       
   231                                                         TSecureId aSecureId )
       
   232     {
       
   233     CCategory* category = iObjectHandler.CategoryL( aCategory );
       
   234     TInt error = KErrNone;
       
   235     if ( category )
       
   236         {
       
   237         
       
   238         TBool stop = EFalse;
       
   239         TInt index = 0;
       
   240         // Loop through the list of events and unregister those.
       
   241         for ( index = 0; index < aEvents.Count() && !stop; index++ )
       
   242             {
       
   243             TInt eventIndex = 0;
       
   244             TEvent removeEvent = aEvents[index];
       
   245             CEvent* eventPtr = category->FindEvent( removeEvent.iEventId, eventIndex );
       
   246             if ( !eventPtr )
       
   247                 {
       
   248                 ERROR_LOG(_L("[Mediator] CMediatorServerEventHandler::UnregisterEventListL: Event not found\n") );
       
   249                 ERROR_TRACE(Print(_L("[Mediator] Failed to remove event %d in category %d of domain %d\n"), removeEvent.iEventId, 
       
   250                                                                                                        aCategory.iCategory.iUid,
       
   251                                                                                                        aCategory.iDomain.iUid ) );
       
   252                 error = KErrMediatorEventNotFound;
       
   253                 stop = ETrue;
       
   254                 }
       
   255             else
       
   256                 {
       
   257                 // Found the event --> is it own registration
       
   258                 if ( eventPtr->SecureId() != aSecureId )
       
   259                     {
       
   260                     ERROR_LOG(_L("[Mediator] CMediatorServerEventHandler::UnregisterEventListL: Secure ID mismatch\n") );
       
   261                     ERROR_TRACE(Print(_L("[Mediator] eventPtr->SecureId()=0x%x, aSecureId=0x%x\n"), eventPtr->SecureId().iId, 
       
   262                                                                                                     aSecureId.iId ) );
       
   263                     error = KErrMediatorSecureIdMismatch;
       
   264                     stop = ETrue;
       
   265                     }
       
   266                 else    // Should be ok to unregister
       
   267                     {
       
   268                     eventPtr->SetCommitState( CItem::ERemoved );
       
   269                     }
       
   270                 }
       
   271             }
       
   272         
       
   273         TRACE(Print(_L("[Mediator Server]\t Events unregistered:\n")));
       
   274         TRACE(Print(_L("[Mediator Server]\t Success/count: %d/%d \tstatus: %d"), index, aEvents.Count(), error ));    
       
   275         
       
   276         // Check error status --> if there's error, need to roll back
       
   277         if ( error != KErrNone )
       
   278             {
       
   279             // Cancel event removal
       
   280             category->RollbackEvents();
       
   281             }
       
   282         else
       
   283             {
       
   284             // Complete event removal
       
   285             category->CommitEvents();
       
   286             // Use the object handler to notify event removal
       
   287             iObjectHandler.EventsRemoved( aCategory.iDomain, 
       
   288                                           aCategory.iCategory, 
       
   289                                           aEvents );
       
   290             }
       
   291         }
       
   292     // Leave in case of error situation
       
   293     User::LeaveIfError( error );
       
   294     }                                                        
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CMediatorServerEventHandler::SubscribeEventListL
       
   298 //  
       
   299 // (other items were commented in a header).
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 void CMediatorServerEventHandler::SubscribeEventListL( 
       
   303                             TMediatorCategory aCategory, 
       
   304                             const REventList& aEvents,
       
   305                             TCapabilitySet aCaps,
       
   306                             MMediatorServerEventObserver* aObserver )
       
   307     {
       
   308     LOG(_L("[Mediator Server]\t CMediatorServerEventHandler::SubscribeEventListL"));
       
   309     TInt error = KErrNone;
       
   310     TBool stop = EFalse;
       
   311     TInt index = 0;
       
   312     // Find domain & category
       
   313     CCategory* category = iObjectHandler.CategoryL( aCategory ); 
       
   314     if ( category )
       
   315         {
       
   316         // Loop through the list of subscribed events
       
   317         for ( index = 0; index < aEvents.Count() && !stop; index++ )
       
   318             {
       
   319             TEvent newEvent = aEvents[index];
       
   320             TInt ignore = 0; // Not used
       
   321             CEvent* eventPtr = category->FindEvent( newEvent.iEventId, ignore );
       
   322             if ( !eventPtr )
       
   323                 {
       
   324                 error = KErrMediatorEventNotFound;
       
   325                 stop = ETrue;   // Partial failure --> stop processing
       
   326                 }
       
   327             else
       
   328                 {   
       
   329                 // Check capabilities 
       
   330                 // Capabilities are checked so that boolean ETrue is returned
       
   331                 // when all parameter caps can be found from aCaps
       
   332                 if ( !aCaps.HasCapabilities( eventPtr->Policy() ) )
       
   333                     {
       
   334 #ifdef _DEBUG
       
   335                     for ( TInt index = 0; index < ECapability_Limit; index++ )
       
   336                         {
       
   337                         TCapabilitySet eventCaps = eventPtr->Policy();
       
   338                         TBool event = eventCaps.HasCapability( (TCapability) index );
       
   339                         TBool requestor = aCaps.HasCapability( (TCapability) index );
       
   340                         if ( event && !requestor )
       
   341                             {
       
   342                             ERROR_TRACE(Print(_L("[Mediator] CMediatorServerEventHandler::SubscribeEventListL: capability %d missing \n"), index ));
       
   343                             ERROR_TRACE(Print(_L("[Mediator] Failed to subscribe event %d in category %d of domain %d\n"), newEvent.iEventId, 
       
   344                                                                                                                            aCategory.iCategory.iUid,
       
   345                                                                                                                            aCategory.iDomain.iUid ) );
       
   346                             }
       
   347                         }
       
   348 #endif  // _DEBUG                  
       
   349                     error = KErrPermissionDenied;
       
   350                     stop = ETrue;
       
   351                     }
       
   352                 // Check (major) version match
       
   353                 if ( newEvent.iVersion.iMajor != eventPtr->Version().iMajor )
       
   354                     {
       
   355                     ERROR_LOG(_L("[Mediator] CMediatorServerEventHandler::SubscribeEventListL: Version mismatch\n"));
       
   356                     ERROR_TRACE(Print(_L("[Mediator] Registered=%d, subscribed=%d \n"), eventPtr->Version().iMajor,
       
   357                                                                                         newEvent.iVersion.iMajor ) );
       
   358                     ERROR_TRACE(Print(_L("[Mediator] Failed to subscribe event %d in category %d of domain %d\n"), newEvent.iEventId, 
       
   359                                                                                                                    aCategory.iCategory.iUid,
       
   360                                                                                                                    aCategory.iDomain.iUid ) );
       
   361                     // There's a major version mismatch
       
   362                     error = KErrMediatorVersionMismatch;
       
   363                     stop = ETrue;
       
   364                     }
       
   365                 if ( !error )   // Everything ok?
       
   366                     {
       
   367                     // Everything is ok, register subscriber
       
   368                     TInt status = eventPtr->AddObserver( aObserver );
       
   369                     // If there's double subscription, ignore error
       
   370                     // otherwise return the error
       
   371                     if ( status &&  status != KErrMediatorAlreadySubscribed )
       
   372                         {
       
   373                         ERROR_TRACE(Print(_L("[Mediator] CMediatorServerEventHandler::SubscribeEventListL: error=%d\n"), status) );
       
   374                         ERROR_TRACE(Print(_L("[Mediator] Failed to subscribe event %d in category %d of domain %d\n"), newEvent.iEventId, 
       
   375                                                                                                                        aCategory.iCategory.iUid,
       
   376                                                                                                                        aCategory.iDomain.iUid ) );
       
   377                         error = status;
       
   378                         stop = ETrue;
       
   379                         }
       
   380                     TRACE(Print(_L("[Mediator Server]\t subscription status: %d\n"), status));
       
   381                     }
       
   382                 }
       
   383             }
       
   384         
       
   385         TRACE(Print(_L("[Mediator Server]\t Events subscribed:\n")));
       
   386         TRACE(Print(_L("[Mediator Server]\t Processed/Total: %d/%d \tstatus: %d"), index, aEvents.Count(), error ));    
       
   387         // Check error status --> if there's error, need to roll back
       
   388         if ( error != KErrNone )
       
   389             {
       
   390             // Loop the subscribed events and unsubscribe those
       
   391             // Index - 1 is because index points to failed item --> stop before processing it again
       
   392             for ( TInt newIndex = 0; newIndex < index - 1; newIndex++ )
       
   393                 {
       
   394                 TEvent event = aEvents[newIndex];
       
   395                 TInt ignore = 0; // Not used
       
   396                 CEvent* eventPtr = category->FindEvent( event.iEventId, ignore );
       
   397                 if ( eventPtr )
       
   398                     {
       
   399                     // Nothing can be done in case of error --> ignore return value
       
   400                     TInt ignore = eventPtr->RemoveObserver( aObserver );
       
   401                     }
       
   402                 }
       
   403             }
       
   404         }
       
   405     // In the end leave if we have error
       
   406     User::LeaveIfError( error );
       
   407       
       
   408     }
       
   409 
       
   410 // -----------------------------------------------------------------------------
       
   411 // CMediatorServerEventHandler::UnsubscribeEventListL
       
   412 //  
       
   413 // (other items were commented in a header).
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 void CMediatorServerEventHandler::UnsubscribeEventListL( 
       
   417                             TMediatorCategory aCategory, 
       
   418                             const REventList& aEvents,
       
   419                             MMediatorServerEventObserver* aObserver )
       
   420     {
       
   421     LOG(_L("[Mediator Server]\t CMediatorServerEventHandler::UnsubscribeEventListL"));
       
   422     // Find correct category
       
   423     CCategory* category = iObjectHandler.CategoryL( aCategory );
       
   424     TInt error = KErrNone;
       
   425     TInt index = 0;
       
   426     
       
   427     if ( category )
       
   428         {
       
   429         TBool stop = EFalse;
       
   430         // Loop through the list of events to be unsubscribed
       
   431         for ( index = 0; index < aEvents.Count() && !stop; index++ )
       
   432             {
       
   433             TEvent event = aEvents[index];
       
   434             TInt ignore = 0; // Not used
       
   435             CEvent* eventPtr = category->FindEvent( event.iEventId, ignore );
       
   436             if ( !eventPtr )
       
   437                 {
       
   438                 ERROR_LOG(_L("[Mediator] CMediatorServerEventHandler::UnsubscribeEventListL: event not found\n"));
       
   439                 ERROR_TRACE(Print(_L("[Mediator] Failed to unsubscribe event %d in category %d of domain %d\n"), event.iEventId, 
       
   440                                                                                                                aCategory.iCategory.iUid,
       
   441                                                                                                                aCategory.iDomain.iUid ) );
       
   442 
       
   443                 error = KErrMediatorEventNotFound;
       
   444                 stop = ETrue;   // Partial failure --> stop processing
       
   445                 }
       
   446             else
       
   447                 {   
       
   448                 // Everything is ok, unsubscribe
       
   449                 TInt status = eventPtr->RemoveObserver( aObserver );
       
   450                 // If there's no subscription existing, ignore error
       
   451                 // otherwise return the error
       
   452                 if ( status != KErrMediatorNoSubscription )
       
   453                     {
       
   454                     ERROR_TRACE(Print(_L("[Mediator] CMediatorServerEventHandler::UnsubscribeEventListL: status=%d\n"), status ) );
       
   455                     ERROR_TRACE(Print(_L("[Mediator] Failed to unsubscribe event %d in category %d of domain %d\n"), event.iEventId, 
       
   456                                                                                                                aCategory.iCategory.iUid,
       
   457                                                                                                                aCategory.iDomain.iUid ) );
       
   458                     error = status;
       
   459                     stop = ETrue;
       
   460                     }
       
   461                 TRACE(Print(_L("[Mediator Server]\t unsubscribe status: %d\n"), status));
       
   462                 }
       
   463             }
       
   464         
       
   465         TRACE(Print(_L("[Mediator Server]\t Events unsubscribed:\n")));
       
   466         TRACE(Print(_L("[Mediator Server]\t Success/count: %d/%d \tstatus: %d"), index, aEvents.Count(), error ));    
       
   467         
       
   468         // Check error status --> if there's error, need to roll back
       
   469         if ( error != KErrNone )
       
   470             {
       
   471             // Loop the unsubscribed events and subscribe those
       
   472             for ( TInt newIndex = 0; newIndex < index; newIndex++ )
       
   473                 {
       
   474                 TEvent event = aEvents[newIndex];
       
   475                 TInt ignore = 0; // Not used
       
   476                 CEvent* eventPtr = category->FindEvent( event.iEventId, ignore );
       
   477                 if ( eventPtr )
       
   478                     {
       
   479                     // Nothing can be done in case of error --> ignore return value
       
   480                     TInt ignore = eventPtr->AddObserver( aObserver );
       
   481                     }
       
   482                 }
       
   483             }
       
   484         }
       
   485     // In the end leave if we have error
       
   486     User::LeaveIfError( error );  
       
   487     }
       
   488 
       
   489 // -----------------------------------------------------------------------------
       
   490 // CMediatorServerEventHandler::RaiseEventL
       
   491 //  
       
   492 // (other items were commented in a header).
       
   493 // -----------------------------------------------------------------------------
       
   494 //
       
   495 void CMediatorServerEventHandler::RaiseEventL( TMediatorCategory aCategory, 
       
   496                                                MediatorService::TEvent aEvent,
       
   497                                                const TDesC8& aData )
       
   498     {
       
   499     LOG(_L("[Mediator Server]\t CMediatorServerEventHandler::RaiseEventL"));
       
   500     // Find correct category
       
   501     CCategory* category = iObjectHandler.CategoryL( aCategory );
       
   502     if ( category )
       
   503         {
       
   504         TInt ignore = 0; // Not used
       
   505         CEvent* eventPtr = category->FindEvent( aEvent.iEventId, ignore );
       
   506         
       
   507         // Check that event was found
       
   508         if ( !eventPtr )
       
   509             {
       
   510             ERROR_LOG(_L("[Mediator] CMediatorServerEventHandler::RaiseEventL: event not found\n"));
       
   511             ERROR_TRACE(Print(_L("[Mediator] Failed to raise event %d in category %d of domain %d\n"), aEvent.iEventId, 
       
   512                                                                                                        aCategory.iCategory.iUid,
       
   513                                                                                                        aCategory.iDomain.iUid ) );
       
   514             User::Leave( KErrMediatorEventNotFound );
       
   515             }
       
   516         
       
   517         // Check the version information match (major
       
   518         if ( eventPtr->Version().iMajor != aEvent.iVersion.iMajor )
       
   519             {
       
   520             ERROR_LOG(_L("[Mediator] CMediatorServerEventHandler::RaiseEventL: Version mismatch\n"));
       
   521             ERROR_TRACE(Print(_L("[Mediator] Registered=%d, subscribed=%d \n"), eventPtr->Version().iMajor,
       
   522                                                                                 aEvent.iVersion.iMajor ) );
       
   523             ERROR_TRACE(Print(_L("[Mediator] Failed to raise event %d in category %d of domain %d\n"), aEvent.iEventId, 
       
   524                                                                                                        aCategory.iCategory.iUid,
       
   525                                                                                                        aCategory.iDomain.iUid ) );                                                                                
       
   526             User::Leave( KErrMediatorVersionMismatch );
       
   527             }
       
   528         
       
   529         
       
   530         RPointerArray<MMediatorServerEventObserver>& observers
       
   531                     = eventPtr->GetObservers();
       
   532                 
       
   533         // Loop through the observer array and send notifications
       
   534         for ( TInt index = 0; index < observers.Count(); index++ )
       
   535             {
       
   536             MMediatorServerEventObserver* observer = observers[index]; 
       
   537             if ( observer )
       
   538                 {
       
   539                 
       
   540                 TRAP_IGNORE( observer->MediatorEventL( aCategory.iDomain,
       
   541                                                        aCategory.iCategory,
       
   542                                                        aEvent.iEventId,
       
   543                                                        aData ) );
       
   544                 }
       
   545             }
       
   546         }
       
   547     }
       
   548 
       
   549 //  End of File