emailservices/nmailagent/src/ssastartupwatcher.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
       
    16 #include "emailtrace.h"
       
    17 
    16 #include "ssastartupwatcher.h"
    18 #include "ssastartupwatcher.h"
    17 
    19 
    18 /*!
    20 /*!
    19     Factory function to create a new instance of the CSSAStartupWatcher
    21     Factory function to create a new instance of the CSSAStartupWatcher
    20     \return new CSSAStartupWatcher object
    22     \return new CSSAStartupWatcher object
    21 */
    23 */
    22 CSSAStartupWatcher* CSSAStartupWatcher::NewL(TStartupCallBack aCallback)
    24 CSSAStartupWatcher* CSSAStartupWatcher::NewL(TStartupCallBack aCallback)
    23 {
    25 {
       
    26     NM_FUNCTION;
       
    27     
    24 	CSSAStartupWatcher* self = new (ELeave) CSSAStartupWatcher(KDmHierarchyIdStartup, 
    28 	CSSAStartupWatcher* self = new (ELeave) CSSAStartupWatcher(KDmHierarchyIdStartup, 
    25 	    KSM2AppServicesDomain3, aCallback);
    29 	    KSM2AppServicesDomain3, aCallback);
    26 	CleanupStack::PushL(self);
    30 	CleanupStack::PushL(self);
    27 	self->ConstructL();
    31 	self->ConstructL();
    28 	CleanupStack::Pop(self);
    32 	CleanupStack::Pop(self);
    33     Factory function to create a new instance of the CSSAStartupWatcher
    37     Factory function to create a new instance of the CSSAStartupWatcher
    34     \return new CSSAStartupWatcher object
    38     \return new CSSAStartupWatcher object
    35 */
    39 */
    36 CSSAStartupWatcher* CSSAStartupWatcher::New(TStartupCallBack aCallback)
    40 CSSAStartupWatcher* CSSAStartupWatcher::New(TStartupCallBack aCallback)
    37 {
    41 {
       
    42     NM_FUNCTION;
       
    43     
    38     CSSAStartupWatcher* self = NULL;
    44     CSSAStartupWatcher* self = NULL;
    39     TRAP_IGNORE( self = NewL(aCallback); );
    45     TRAP_IGNORE( self = NewL(aCallback); );
    40     return self;
    46     return self;
    41 }
    47 }
    42 
    48 
    49 CSSAStartupWatcher::CSSAStartupWatcher(TDmHierarchyId aHierarchyId, 
    55 CSSAStartupWatcher::CSSAStartupWatcher(TDmHierarchyId aHierarchyId, 
    50     TDmDomainId aDomainId, TStartupCallBack aCallback)
    56     TDmDomainId aDomainId, TStartupCallBack aCallback)
    51 : CDmDomain(aHierarchyId,aDomainId), 
    57 : CDmDomain(aHierarchyId,aDomainId), 
    52   iCallback(aCallback)
    58   iCallback(aCallback)
    53 {
    59 {
       
    60     NM_FUNCTION;
    54 }
    61 }
    55 
    62 
    56 /*!
    63 /*!
    57     Destructor
    64     Destructor
    58 */
    65 */
    59 CSSAStartupWatcher::~CSSAStartupWatcher()
    66 CSSAStartupWatcher::~CSSAStartupWatcher()
    60 {
    67 {
       
    68     NM_FUNCTION;
       
    69     
    61 	Cancel();
    70 	Cancel();
    62 }
    71 }
    63 
    72 
    64 /**
    73 /**
    65 Second-stage constructor.
    74 Second-stage constructor.
    67 This method indicates how the CWatcherSSAStartupMgr interacts with the
    76 This method indicates how the CWatcherSSAStartupMgr interacts with the
    68 Domain manager to keep aware of the startup state change.
    77 Domain manager to keep aware of the startup state change.
    69 */
    78 */
    70 void CSSAStartupWatcher::ConstructL()
    79 void CSSAStartupWatcher::ConstructL()
    71 {
    80 {
       
    81     NM_FUNCTION;
       
    82     
    72 	// Connect to the Domain Manager
    83 	// Connect to the Domain Manager
    73 	CDmDomain::ConstructL();
    84 	CDmDomain::ConstructL();
    74 
    85 
    75 	// Get the start-up state from the Domain Manager.
    86 	// Get the start-up state from the Domain Manager.
    76 	TDmDomainState state = GetState();
    87 	TDmDomainState state = GetState();
    92 /*!
   103 /*!
    93     Notify state change
   104     Notify state change
    94 */
   105 */
    95 void CSSAStartupWatcher::NotifyState(TInt aValue) 
   106 void CSSAStartupWatcher::NotifyState(TInt aValue) 
    96 {
   107 {
       
   108     NM_FUNCTION;
       
   109     
    97     (*iCallback)(aValue);
   110     (*iCallback)(aValue);
    98 }
   111 }
    99 
   112 
   100 /*!
   113 /*!
   101     Executed when the startup state change is done, it does the same thing
   114     Executed when the startup state change is done, it does the same thing
   102     as the method InitialiseL().
   115     as the method InitialiseL().
   103 */
   116 */
   104 void CSSAStartupWatcher::RunL()
   117 void CSSAStartupWatcher::RunL()
   105 {
   118 {
       
   119     NM_FUNCTION;
       
   120     
   106 	// Leave if our previous request to be notified a state change has
   121 	// Leave if our previous request to be notified a state change has
   107 	// returned an error and let RunError handle this.
   122 	// returned an error and let RunError handle this.
   108 	if (iStatus.Int()!=KErrNone) {
   123 	if (iStatus.Int()!=KErrNone) {
   109 	    NotifyState( iStatus.Int() );
   124 	    NotifyState( iStatus.Int() );
   110 	}
   125 	}