58 // CTMShutdownObserver::ConstructL() |
59 // CTMShutdownObserver::ConstructL() |
59 // --------------------------------------------------------------------------- |
60 // --------------------------------------------------------------------------- |
60 // |
61 // |
61 void CTMShutdownObserver::ConstructL() |
62 void CTMShutdownObserver::ConstructL() |
62 { |
63 { |
|
64 TN_DEBUG1( "CTMShutdownObserver::ConstructL()" ); |
63 // define P&S property types |
65 // define P&S property types |
64 if (iDefineKey) |
66 if (iDefineKey) |
65 { |
67 { |
|
68 TN_DEBUG1( "CTMShutdownObserver::ConstructL() define" ); |
66 RProperty::Define(iKeyCategory,iPropertyKey, |
69 RProperty::Define(iKeyCategory,iPropertyKey, |
67 RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy); |
70 RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy); |
68 } |
71 } |
69 |
72 |
70 // attach to the property |
73 // attach to the property |
71 TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread); |
74 TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread); |
|
75 TN_DEBUG2( "CTMShutdownObserver::ConstructL() attach err = %d", err ); |
72 User::LeaveIfError(err); |
76 User::LeaveIfError(err); |
73 |
77 |
74 // wait for the previously attached property to be updated |
78 // wait for the previously attached property to be updated |
75 iProperty.Subscribe(iStatus); |
79 iProperty.Subscribe(iStatus); |
|
80 TN_DEBUG1( "CTMShutdownObserver::ConstructL() subscribe" ); |
76 SetActive(); |
81 SetActive(); |
77 } |
82 } |
78 |
83 |
79 // --------------------------------------------------------------------------- |
84 // --------------------------------------------------------------------------- |
80 // CTMShutdownObserver::~CTMShutdownObserver() |
85 // CTMShutdownObserver::~CTMShutdownObserver() |
81 // --------------------------------------------------------------------------- |
86 // --------------------------------------------------------------------------- |
82 // |
87 // |
83 CTMShutdownObserver::~CTMShutdownObserver() |
88 CTMShutdownObserver::~CTMShutdownObserver() |
84 { |
89 { |
|
90 TN_DEBUG1( "CTMShutdownObserver::~CTMShutdownObserver()" ); |
85 Cancel(); |
91 Cancel(); |
86 iProperty.Close(); |
92 iProperty.Close(); |
87 } |
93 } |
88 |
94 |
89 // --------------------------------------------------------------------------- |
95 // --------------------------------------------------------------------------- |
90 // CTMShutdownObserver::RunL() |
96 // CTMShutdownObserver::RunL() |
91 // --------------------------------------------------------------------------- |
97 // --------------------------------------------------------------------------- |
92 // |
98 // |
93 void CTMShutdownObserver::RunL() |
99 void CTMShutdownObserver::RunL() |
94 { |
100 { |
|
101 TN_DEBUG2( "CTMShutdownObserver::RunL(%d)", iStatus.Int() ); |
95 // resubscribe before processing new value to prevent missing updates |
102 // resubscribe before processing new value to prevent missing updates |
96 iProperty.Subscribe(iStatus); |
103 iProperty.Subscribe(iStatus); |
97 SetActive(); |
104 SetActive(); |
98 |
105 |
99 // retrieve the value |
106 // retrieve the value |
100 TInt value = 0; |
107 TInt value = 0; |
101 iProperty.Get(value); |
108 TInt err = iProperty.Get(value); |
|
109 |
|
110 TN_DEBUG2( "CTMShutdownObserver::RunL() Get err = %d", err ); |
102 |
111 |
103 // observer callback |
112 // observer callback |
104 if (value) |
113 if (value) |
105 { |
114 { |
106 iObserver.ShutdownNotification(); |
115 iObserver.ShutdownNotification(); |