Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // domain\src\domaincli.cpp
19 #include <e32base_private.h>
20 #include <e32property.h>
22 #include <domainmember.h>
23 #include <domainmanager.h>
24 #include "domainobserver.h"
25 #include "domainsrv.h"
27 #define __DM_PANIC(aError) User::Panic(_L("domainCli.cpp"), (-(aError)) | (__LINE__ << 16))
28 #define __DM_ASSERT(aCond) __ASSERT_DEBUG(aCond,User::Panic(_L("domainCli.cpp; assertion failed"), __LINE__))
30 TInt RDmDomainSession::Connect(TDmHierarchyId aHierarchyId, TDmDomainId aDomainId, TUint* aKey)
32 TInt r = RSessionBase::CreateSession(KDmDomainServerNameLit, KDmDomainServerVersion, 1);
35 TIpcArgs a( (TInt)aHierarchyId, (TInt)aDomainId );
36 r = RSessionBase::SendReceive(EDmDomainJoin, a);
39 RSessionBase::Close();
42 *aKey = DmStatePropertyKey(
49 void RDmDomainSession::Acknowledge(TInt aValue, TInt aError)
51 __DM_ASSERT(Handle() != KNullHandle);
53 TIpcArgs a(aValue, aError);
54 TInt r = RSessionBase::SendReceive(EDmStateAcknowledge, a);
59 void RDmDomainSession::RequestTransitionNotification()
61 __DM_ASSERT(Handle() != KNullHandle);
62 TInt r = RSessionBase::SendReceive(EDmStateRequestTransitionNotification);
67 void RDmDomainSession::CancelTransitionNotification()
69 if (Handle() != KNullHandle)
71 TInt r = RSessionBase::SendReceive(EDmStateCancelTransitionNotification);
80 Connects to the domain identified by the specified domain Id.
82 To connect to the root domain, which has the Id KDmIdRoot,
83 the capability WriteDeviceData is required.
85 Once connected, an application can use this RDmDomain object to read
86 the domain's power state and to request notification
87 when the power state changes.
89 @param aDomainId The identifier of the domain to be connected to.
91 @return KErrNone, if successful; otherwise one of the other system-wide
92 or domain manager specific error codes.
94 @capability WriteDeviceData If aDomainId==KDmIdRoot
96 EXPORT_C TInt RDmDomain::Connect(TDmDomainId aDomainId)
99 TInt r = iSession.Connect(KDmHierarchyIdPower, aDomainId, &key);
102 r = iStateProperty.Attach(KUidDmPropertyCategory, key);
115 Connects to the domain identified by the specified domain Id.
117 To connect to the root domain, which has the Id KDmIdRoot,
118 the capability WriteDeviceData is required.
120 Once connected, an application can use this RDmDomain object to read
121 the domain's state and to request notification
122 when the state changes.
124 @param aHierarchyId The Id of the domain hierarchy to connect to.
125 @param aDomainId The identifier of the domain to be connected to.
127 @return KErrNone, if successful; otherwise one of the other system-wide
128 or domain manager specific error codes.
130 @capability WriteDeviceData If aDomainId==KDmIdRoot
132 EXPORT_C TInt RDmDomain::Connect(TDmHierarchyId aHierarchyId, TDmDomainId aDomainId)
135 TInt r = iSession.Connect(aHierarchyId, aDomainId, &key);
138 r = iStateProperty.Attach(KUidDmPropertyCategory, key);
151 Disconnects from the associated domain.
153 If this object is not connected to any domain, then it returns silently.
155 EXPORT_C void RDmDomain::Close()
158 iStateProperty.Close();
165 Requests notification when the domain's state changes.
167 This is an asynchronous request that completes when
168 the domain's state changes.
170 @param aStatus The request status object for this asynchronous request.
172 @see RDmDomain::CancelTransitionNotification()
174 EXPORT_C void RDmDomain::RequestTransitionNotification(TRequestStatus& aStatus)
176 iStateProperty.Subscribe(aStatus);
177 iSession.RequestTransitionNotification();
184 Cancels an outstanding notification request.
186 Any outstanding notification request completes with KErrCancel.
188 EXPORT_C void RDmDomain::CancelTransitionNotification()
190 iSession.CancelTransitionNotification();
191 iStateProperty.Cancel();
198 Gets the domain's power state.
200 An application normally calls this function after a notification request
201 has completed. It then performs any application-dependent action demanded by
202 the power state, and then acknowledges the state transition.
204 Note that the domain manager requires any domain power state change to be
205 acknowledged by all applications connected to the domain.
207 @return The connected domain's power state.
209 @see RDmDomain::AcknowledgeLastState()
211 EXPORT_C TPowerState RDmDomain::GetPowerState()
214 TInt r = iStateProperty.Get(value);
217 iLastStatePropertyValue = value;
218 return (TPowerState) DmStateFromPropertyValue(value);
225 Acknowledges the state change.
227 An application must acknowledge that it has performed all actions required
228 by the last known state of the domain.
230 EXPORT_C void RDmDomain::AcknowledgeLastState()
232 iSession.Acknowledge(iLastStatePropertyValue, KErrNone);
237 Acknowledges the state change with the specified error
239 An application must acknowledge that it has performed all actions required
240 by the last known state of the domain.
242 @param aError KDmErrNotJoin if domain is not part of the hierarhcy or a
243 system wide error value associated with the state change.
245 EXPORT_C void RDmDomain::AcknowledgeLastState(TInt aError)
247 iSession.Acknowledge(iLastStatePropertyValue, aError);
253 Gets the domain's state.
255 An application normally calls this function after a notification request
256 has completed. It then performs any application-dependent action demanded by
257 the state, and then acknowledges the state transition.
259 Note, that the domain manager requires any domain state change to be
260 acknowledged by all applications connected to the domain.
262 @return The connected domain's state.
264 EXPORT_C TDmDomainState RDmDomain::GetState()
267 TInt r = iStateProperty.Get(value);
270 iLastStatePropertyValue = value;
271 return DmStateFromPropertyValue(value);
274 TInt RDmManagerSession::Connect()
276 __DM_ASSERT(Handle() == KNullHandle);
278 return RSessionBase::CreateSession(
279 KDmManagerServerNameLit,
280 KDmManagerServerVersion,
284 TInt RDmManagerSession::ConnectObserver(TDmHierarchyId aHierarchyId)
290 TIpcArgs a( (TInt)aHierarchyId);
291 r = RSessionBase::SendReceive(EDmObserverJoin, a);
294 RSessionBase::Close();
300 TInt RDmManagerSession::Connect(TDmHierarchyId aHierarchyId)
306 TIpcArgs a( (TInt)aHierarchyId);
307 r = RSessionBase::SendReceive(EDmHierarchyJoin, a);
310 RSessionBase::Close();
316 void RDmManagerSession::RequestDomainTransition(
317 TDmDomainId aDomainId,
318 TDmDomainState aState,
319 TDmTraverseDirection aDirection,
320 TRequestStatus& aStatus)
322 __DM_ASSERT(Handle() != KNullHandle);
324 if(aDirection < 0 || aDirection > ETraverseMax)
325 __DM_PANIC(KErrArgument);
327 TIpcArgs a(aDomainId, aState, aDirection);
328 RSessionBase::SendReceive(EDmRequestDomainTransition, a, aStatus);
331 void RDmManagerSession::CancelTransition()
333 if (Handle() != KNullHandle)
335 TInt r = RSessionBase::SendReceive(EDmCancelTransition);
341 void RDmManagerSession::CancelObserver()
343 if (Handle() != KNullHandle)
345 TInt r = RSessionBase::SendReceive(EDmObserverCancel);
351 void RDmManagerSession::RequestSystemTransition(
352 TDmDomainState aState,
353 TDmTraverseDirection aDirection,
354 TRequestStatus& aStatus)
356 __DM_ASSERT(Handle() != KNullHandle);
358 TIpcArgs a(aState, aDirection);
359 RSessionBase::SendReceive(EDmRequestSystemTransition, a, aStatus);
362 TInt RDmManagerSession::AddDomainHierarchy(TDmHierarchyId aHierarchyId)
364 __DM_ASSERT(Handle() != KNullHandle);
366 TIpcArgs a( (TInt)aHierarchyId);
367 TInt r = RSessionBase::SendReceive(EDmHierarchyAdd, a);
372 TInt RDmManagerSession::GetTransitionFailureCount()
374 __DM_ASSERT(Handle() != KNullHandle);
376 return RSessionBase::SendReceive(EDmGetTransitionFailureCount);
379 TInt RDmManagerSession::GetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailures)
381 __DM_ASSERT(Handle() != KNullHandle);
383 aTransitionFailures.Reset();
387 TInt failureCount = GetTransitionFailureCount();
388 if (failureCount <= 0)
391 TTransitionFailure* failures = new TTransitionFailure[failureCount];
393 return(KErrNoMemory);
394 TPtr8 dataPtr(reinterpret_cast<TUint8*>(failures), failureCount * sizeof(TTransitionFailure));
396 TIpcArgs a(&dataPtr);
397 err = RSessionBase::SendReceive(EDmGetTransitionFailures, a);
401 for (TInt i=0; i<failureCount; i++)
402 aTransitionFailures.Append(failures[i]);
410 TInt RDmManagerSession::StartObserver(TDmDomainId aDomainId, TDmNotifyType aNotifyType)
412 __DM_ASSERT(Handle() != KNullHandle);
414 TIpcArgs a(aDomainId,aNotifyType);
415 return(RSessionBase::SendReceive(EDmObserverStart,a));
418 void RDmManagerSession::GetNotification(TRequestStatus& aStatus)
420 __DM_ASSERT(Handle() != KNullHandle);
421 RSessionBase::SendReceive(EDmObserverNotify,aStatus);
424 TInt RDmManagerSession::GetEventCount()
426 __DM_ASSERT(Handle() != KNullHandle);
427 return(RSessionBase::SendReceive(EDmObserverEventCount));
430 TInt RDmManagerSession::GetEvents(RArray<const TTransInfo>& aTransitions)
432 __DM_ASSERT(Handle() != KNullHandle);
434 aTransitions.Reset();
437 TInt count = GetEventCount();
438 // This shouldn't happen unless something gone terribly wrong
442 TTransInfo* trans = new TTransInfo[count];
444 return(KErrNoMemory);
446 TPtr8 dataPtr(reinterpret_cast<TUint8*>(trans), count * sizeof(TTransInfo));
448 TIpcArgs a(&dataPtr);
449 TInt ret=RSessionBase::SendReceive(EDmObserverGetEvent, a);
453 for (TInt i=0; i<count; i++)
454 aTransitions.Append(trans[i]);
462 TInt RDmManagerSession::ObserverDomainCount()
464 __DM_ASSERT(Handle() != KNullHandle);
465 return(RSessionBase::SendReceive(EDmObserveredCount));
472 EXPORT_C TInt RDmDomainManager::WaitForInitialization()
475 TInt r = prop.Attach(KUidDmPropertyCategory, KDmPropertyKeyInit);
480 TInt count = RThread().RequestCount();
483 TRequestStatus status;
486 prop.Subscribe(status);
491 if (value) break; // initialized
492 // property exists but the server is not intialized yet
496 if (r != KErrNotFound) break; // error
497 // property doesn't exist yet
499 User::WaitForRequest(status);
500 if (status.Int() != KErrNone)
504 if (status.Int() == KRequestPending)
507 User::WaitForRequest(status);
511 __DM_ASSERT(RThread().RequestCount() == count);
520 Opens a controlling connection to the standard power domain hierarchy
521 in the domain manager.
523 The domain manger allows only one open connection at any one time to the
524 power domain hierarchy.
525 Connection is usually made by the power policy entity.
527 @return KErrNone, if successful; otherwise one of the other system-wide
528 or the domain manager specific error codes.
530 @see KDmErrAlreadyJoin
532 EXPORT_C TInt RDmDomainManager::Connect()
534 return iSession.Connect(KDmHierarchyIdPower);
541 Opens a controlling connection to a specific domain hieararchy owned
542 by the domain manager.
544 The domain manger allows only one open connection at any one time to a
545 particular hierarchy.
547 @param aHierarchyId The Id of the domain hierarchy to connect to.
549 @return KErrNone, if successful; otherwise one of the other system-wide
550 or domain manager specific error codes.
552 @see KDmErrAlreadyJoin
553 @see KErrBadHierarchyId
555 EXPORT_C TInt RDmDomainManager::Connect(TDmHierarchyId aHierarchyId)
558 return iSession.Connect(aHierarchyId);
565 Closes this connection to the domain manager.
567 If there is no existing connection, then it returns silently.
569 EXPORT_C void RDmDomainManager::Close()
578 Requests a system-wide power state transition.
580 The domain hierarchy is traversed in the default direction
582 @param aState The target power state.
583 @param aStatus The request status object for this asynchronous request.
585 @see RDmDomainManager::CancelTransition()
587 EXPORT_C void RDmDomainManager::RequestSystemTransition(TPowerState aState, TRequestStatus& aStatus)
589 if (aState == EPwActive)
591 TRequestStatus* status = &aStatus;
592 User::RequestComplete(status, KErrArgument);
595 RequestSystemTransition((TDmDomainState) aState, ETraverseDefault, aStatus);
602 Requests a system-wide power shutdown.
604 This is a request to change the system's power state to EPwOff.
605 This call does not return; the system can only return by rebooting.
607 EXPORT_C void RDmDomainManager::SystemShutdown()
609 TRequestStatus status;
610 RequestSystemTransition((TDmDomainState) EPwOff, ETraverseDefault, status);
611 User::WaitForRequest(status);
619 Requests a domain state transition.
621 The domain hierarchy is traversed in the default direction.
623 @param aDomainId The Id of the domain for which the state transition
625 @param aState The target state.
626 @param aStatus The request status object for this asynchronous request.
628 @see RDmDomainManager::CancelTransition()
630 EXPORT_C void RDmDomainManager::RequestDomainTransition(
631 TDmDomainId aDomainId,
633 TRequestStatus& aStatus)
635 RequestDomainTransition(aDomainId,(TDmDomainState) aState, ETraverseDefault, aStatus);
642 Cancels a state transition, whether initiated by a call
643 to RequestSystemTransition() or RequestDomainTransition().
645 An outstanding state transition request completes with KErrCancel.
647 EXPORT_C void RDmDomainManager::CancelTransition()
649 iSession.CancelTransition();
656 Requests a system-wide state transition.
658 The domain hierarchy is traversed in the specified direction.
660 @param aState The target state.
661 @param aDirection The direction in which to traverse the hierarchy
662 @param aStatus The request status object for this asynchronous request.
664 @see RDmDomainManager::CancelTransition()
666 @panic domainCli.cpp; assertion failed VARNUM if the numerical value of aDirection
667 is greater than the value of ETraverseMax. NOTE: VARNUM is the line number
668 in the source code and may change if the implementation changes.
670 EXPORT_C void RDmDomainManager::RequestSystemTransition(
671 TDmDomainState aState,
672 TDmTraverseDirection aDirection,
673 TRequestStatus& aStatus)
675 __DM_ASSERT(aDirection <= ETraverseMax);
676 iSession.RequestSystemTransition(aState, aDirection, aStatus);
683 Requests a domain state transition.
685 The domain hierarchy is traversed in the specified direction
687 @param aDomainId The Id of the domain for which the state transition
689 @param aState The target state.
690 @param aDirection The direction in which to traverse the hierarchy.
691 @param aStatus The request status object for this asynchronous request.
693 @see RDmDomainManager::CancelTransition()
695 @panic domainCli.cpp; assertion failed VARNUM if the numerical value of aDirection
696 is greater than the value of ETraverseMax. NOTE: VARNUM is the line number
697 in the source code and may change if the implementation changes.
699 EXPORT_C void RDmDomainManager::RequestDomainTransition(
700 TDmDomainId aDomainId,
701 TDmDomainState aState,
702 TDmTraverseDirection aDirection,
703 TRequestStatus& aStatus)
705 __DM_ASSERT(aDirection <= ETraverseMax);
706 iSession.RequestDomainTransition(aDomainId, aState, aDirection, aStatus);
713 Adds a domain hierarchy to the domain manager.
715 @param aHierarchyId The Id of the domain hierarchy to be added.
717 @return KErrNone if successful; otherwise one of the other system-wide
718 or domain manager specific error codes.
720 EXPORT_C TInt RDmDomainManager::AddDomainHierarchy(TDmHierarchyId aHierarchyId)
722 RDmManagerSession session;
723 TInt r = session.Connect();
726 r = session.AddDomainHierarchy(aHierarchyId);
734 Requests a list of transition failures since the last transition request.
736 @param aTransitionFailures A client-supplied array of TTransitionFailure objects which
737 on exit will contain the failures that have occurred since the last transition
739 @pre The session must be connected.
741 @return KErrNone, if successful; otherwise one of the other system-wide
742 or domain manager specific error codes.
744 EXPORT_C TInt RDmDomainManager::GetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailures)
746 return iSession.GetTransitionFailures(aTransitionFailures);
752 Gets the number of transition failures since the last transition request.
754 @return The number of failures, if successful; otherwise one of the other system-wide
755 or domain manager specific error codes.
757 EXPORT_C TInt RDmDomainManager::GetTransitionFailureCount()
759 return iSession.GetTransitionFailureCount();
769 Adds this active object to the active scheduler. The priority of the active object
770 is the standard value, i.e. CActive::EPriorityStandard.
772 @param aHierarchyId The Id of the domain hierarchy to connect to.
773 @param aDomainId The Id of the domain to connect to.
776 @see CActive::TPriority
778 EXPORT_C CDmDomain::CDmDomain(TDmHierarchyId aHierarchyId, TDmDomainId aDomainId) :
779 CActive(CActive::EPriorityStandard),
780 iHierarchyId(aHierarchyId),
783 CActiveScheduler::Add(this);
792 Closes the session to the domain manager.
794 EXPORT_C CDmDomain::~CDmDomain()
804 Second-phase constructor.
806 The function attempts to connect to the domain specified in the constructor.
808 @leave One of the system-wide error codes
810 EXPORT_C void CDmDomain::ConstructL()
812 User::LeaveIfError(iDomain.Connect(iHierarchyId, iDomainId));
819 Requests notification when the domain's state changes.
821 RunL() will be called when this happens.
823 EXPORT_C void CDmDomain::RequestTransitionNotification()
825 __DM_ASSERT(!IsActive());
826 iDomain.RequestTransitionNotification(iStatus);
834 Cancels an outstanding notification request.
836 Any outstanding notification request completes with KErrCancel.
838 EXPORT_C void CDmDomain::DoCancel()
840 iDomain.CancelTransitionNotification();
847 Acknowledges the last state change.
849 An application must acknowledge that it has performed all actions required
850 by the last known state of the domain.
852 @param aError The error to return to the domain manager. The client should
853 set this to KErrNone if it successfully transitioned to the
854 new state or to one of the system-wide error codes.
856 EXPORT_C void CDmDomain::AcknowledgeLastState(TInt aError)
858 iDomain.AcknowledgeLastState(aError);
865 Gets the domain's state.
867 An application normally calls this function after a notification request
868 has completed. It then performs any application-dependent action demanded by
869 the state, and then acknowledges the state transition.
871 @return The connected domain's state.
873 EXPORT_C TDmDomainState CDmDomain::GetState()
875 return iDomain.GetState();
883 Adds this active object to the active scheduler.
885 @param aHierarchyId The Id of the domain hierarchy to connect to
887 EXPORT_C CDmDomainManager::CDmDomainManager(TDmHierarchyId aHierarchyId) :
888 CActive(CActive::EPriorityStandard),
889 iHierarchyId(aHierarchyId)
891 CActiveScheduler::Add(this);
900 Closes the session to the domain manager.
902 EXPORT_C CDmDomainManager::~CDmDomainManager()
912 The second-phase constructor.
914 This function attempts to connect to the hierarchy
915 specified in the constructor.
917 @leave One of the system-wide error codes.
919 EXPORT_C void CDmDomainManager::ConstructL()
921 User::LeaveIfError(iManager.Connect(iHierarchyId));
928 Requests a system-wide state transition.
930 The domain hierarchy is traversed in the specified direction
932 @param aState The target state.
933 @param aDirection The direction in which to traverse the hierarchy.
935 EXPORT_C void CDmDomainManager::RequestSystemTransition(TDmDomainState aState, TDmTraverseDirection aDirection)
937 __DM_ASSERT(!IsActive());
938 iStatus = KRequestPending;
939 iManager.RequestSystemTransition(aState, aDirection, iStatus);
947 Requests a domain state transition.
949 The domain hierarchy is traversed in the specified direction.
951 @param aDomain The Id of the domain for which the state transition
953 @param aState The target state.
954 @param aDirection The direction in which to traverse the hierarchy.
956 EXPORT_C void CDmDomainManager::RequestDomainTransition(TDmDomainId aDomain, TDmDomainState aState, TDmTraverseDirection aDirection)
958 __DM_ASSERT(!IsActive());
959 iStatus = KRequestPending;
960 iManager.RequestDomainTransition(aDomain, aState, aDirection, iStatus);
968 Adds a domain hierarchy to the domain manager.
970 @param aHierarchyId The Id of the domain hierarchy to add
972 @return KErrNone if successful; otherwise one of the other system-wide
973 or domain manager specific error codes.
975 EXPORT_C TInt CDmDomainManager::AddDomainHierarchy(TDmHierarchyId aHierarchyId)
977 RDmManagerSession session;
978 TInt r = session.Connect();
981 r = session.AddDomainHierarchy(aHierarchyId);
991 Cancels a pending event.
993 EXPORT_C void CDmDomainManager::DoCancel()
995 iManager.CancelTransition();
1002 Requests a list of transition failures since the last transition request.
1004 @param aTransitionFailures A client-supplied array of TTransitionFailure objects which
1005 on exit will contain the failures that have occurred since the last transition
1007 @pre The session must be connected.
1009 @return KErrNone, if successful; otherwise one of the other system-wide
1010 or domain manager specific error codes.
1012 EXPORT_C TInt CDmDomainManager::GetTransitionFailures(RArray<const TTransitionFailure>& aTransitionFailures)
1014 return iManager.GetTransitionFailures(aTransitionFailures);
1021 Gets the number of transition failures since the last transition request.
1023 @return The number of failures if successful, otherwise one of the other system-wide
1024 or domain manager specific error codes.
1026 EXPORT_C TInt CDmDomainManager::GetTransitionFailureCount()
1028 return iManager.GetTransitionFailureCount();
1034 CHierarchyObserver::CHierarchyObserver(MHierarchyObserver& aHierarchyObserver, TDmHierarchyId aHierarchyId):
1035 CActive(CActive::EPriorityStandard),
1036 iHierarchyId(aHierarchyId),
1037 iObserver(aHierarchyObserver)
1039 iTransitionEvents.Reset();
1040 CActiveScheduler::Add(this);
1047 Constructs a new observer on the domain hierarchy.
1049 Note that only one observer per domain hierarchy is allowed.
1051 @param aHierarchyObserver The implementation of the interface to the domain manager.
1052 @param aHierarchyId The Id of the domain hierarchy.
1054 @return The newly created CHierarchyObserver object.
1056 EXPORT_C CHierarchyObserver* CHierarchyObserver::NewL(MHierarchyObserver& aHierarchyObserver,TDmHierarchyId aHierarchyId)
1058 CHierarchyObserver* observer=new(ELeave)CHierarchyObserver(aHierarchyObserver,aHierarchyId);
1060 CleanupStack::PushL(observer);
1061 User::LeaveIfError(observer->iSession.ConnectObserver(aHierarchyId));
1062 CleanupStack::Pop();
1073 Frees resources prior to destruction of the object.
1075 EXPORT_C CHierarchyObserver::~CHierarchyObserver()
1079 iTransitionEvents.Reset();
1082 void CHierarchyObserver::DoCancel()
1084 iObserverStarted=EFalse;
1085 iSession.CancelObserver();
1088 void CHierarchyObserver::RunL()
1090 // Process the reply to client's request for domain transition/failure
1094 TInt ret= iSession.GetEvents(iTransitionEvents);
1096 User::LeaveIfError(ret);
1098 TInt count = iTransitionEvents.Count();
1100 for(TInt i=0;i<count;i++)
1102 if(iTransitionEvents[i].iError==KErrNone)
1103 iObserver.TransProgEvent(iTransitionEvents[i].iDomainId,iTransitionEvents[i].iState);
1104 else if(iTransitionEvents[i].iError==KDmErrOutstanding)
1105 iObserver.TransReqEvent(iTransitionEvents[i].iDomainId,iTransitionEvents[i].iState);
1107 iObserver.TransFailEvent(iTransitionEvents[i].iDomainId,iTransitionEvents[i].iState,iTransitionEvents[i].iError);
1117 Starts the observer.
1119 @param aDomainId The Id of the domain to which the obsever is attached.
1120 @param aNotifyType The type of notifications of interest to the observer.
1122 @return KErrNone on successful start, otherwise one of the other system wide error codes.
1124 EXPORT_C TInt CHierarchyObserver::StartObserver(TDmDomainId aDomainId, TDmNotifyType aNotifyType)
1126 iNotifyType=aNotifyType;
1127 iDomainId=aDomainId;
1129 TInt ret=iSession.StartObserver(iDomainId, iNotifyType);
1132 iObserverStarted=ETrue;
1143 @return KErrNone if successful; KDmErrBadSequence, if the observer
1144 has not already started.
1146 EXPORT_C TInt CHierarchyObserver::StopObserver()
1148 if(!iObserverStarted)
1149 return(KDmErrBadSequence);
1154 void CHierarchyObserver::GetNotification()
1156 iSession.GetNotification(iStatus);
1161 Gets the number of domains that are being observed.
1163 This value is the number of children of the domain member to which the observer
1164 is attached, including itself.
1166 @return The number of observed domain members.
1167 One of the other system wide error codes may be returned on failure;
1168 specifically KErrNotFound if the observer is not already started.
1170 EXPORT_C TInt CHierarchyObserver::ObserverDomainCount()
1172 if(!iObserverStarted)
1173 return KErrNotFound;
1174 return(iSession.ObserverDomainCount());