28 // --------------------------------------------------------- |
28 // --------------------------------------------------------- |
29 // |
29 // |
30 CActiveApDbNotifier::CActiveApDbNotifier( CActiveApDb& aDb ) |
30 CActiveApDbNotifier::CActiveApDbNotifier( CActiveApDb& aDb ) |
31 : CActive( EPriorityStandard ) |
31 : CActive( EPriorityStandard ) |
32 { |
32 { |
33 iActiveDb = &aDb; |
|
34 CActiveScheduler::Add( this ); |
|
35 } |
33 } |
36 |
34 |
37 // --------------------------------------------------------- |
35 // --------------------------------------------------------- |
38 // CActiveApDbNotifier::~CActiveApDbNotifier |
36 // CActiveApDbNotifier::~CActiveApDbNotifier |
39 // --------------------------------------------------------- |
37 // --------------------------------------------------------- |
40 // |
38 // |
41 CActiveApDbNotifier::~CActiveApDbNotifier() |
39 CActiveApDbNotifier::~CActiveApDbNotifier() |
42 { |
40 { |
43 Cancel(); |
|
44 } |
41 } |
45 |
42 |
46 // --------------------------------------------------------- |
43 // --------------------------------------------------------- |
47 // CActiveApDbNotifier::RunL |
44 // CActiveApDbNotifier::RunL |
48 // --------------------------------------------------------- |
45 // --------------------------------------------------------- |
49 // |
46 // |
50 void CActiveApDbNotifier::RunL() |
47 void CActiveApDbNotifier::RunL() |
51 { |
48 { |
52 if ( iStatus == KErrCancel ) |
|
53 { |
|
54 // Do nothing. |
|
55 } |
|
56 else |
|
57 { |
|
58 // first store status, because re-schedule will be earlier |
|
59 // than notifying clients. Reason: |
|
60 // clients can leave but re-schedule MUST happen anyway, |
|
61 // to keep the notifier alive even if any client leaves |
|
62 TRequestStatus tempstatus( iStatus ); |
|
63 |
|
64 if ( iStatus == RDbNotifier::EClose ) |
|
65 { |
|
66 // Finish if the database is closed. |
|
67 NotifyChange(); |
|
68 } |
|
69 else |
|
70 { |
|
71 // Reschedule automatically (as long as the database is open). |
|
72 NotifyChange(); |
|
73 } |
|
74 // and now let clients handle their stuff... |
|
75 TRAP_IGNORE( iActiveDb->HandleDbEventL( tempstatus.Int() ) ); |
|
76 } |
|
77 } |
49 } |
78 |
50 |
79 |
51 |
80 // --------------------------------------------------------- |
52 // --------------------------------------------------------- |
81 // CActiveApDbNotifier::DoCancel |
53 // CActiveApDbNotifier::DoCancel |
82 // --------------------------------------------------------- |
54 // --------------------------------------------------------- |
83 // |
55 // |
84 void CActiveApDbNotifier::DoCancel() |
56 void CActiveApDbNotifier::DoCancel() |
85 { |
57 { |
86 Stop(); |
|
87 } |
58 } |
88 |
59 |
89 |
60 |
90 // --------------------------------------------------------- |
61 // --------------------------------------------------------- |
91 // CActiveApDbNotifier::Stop |
62 // CActiveApDbNotifier::Stop |
92 // --------------------------------------------------------- |
63 // --------------------------------------------------------- |
93 // |
64 // |
94 void CActiveApDbNotifier::Stop() |
65 void CActiveApDbNotifier::Stop() |
95 { |
66 { |
96 iActiveDb->Database()->CancelRequestNotification(); |
|
97 } |
67 } |
98 |
68 |
99 // --------------------------------------------------------- |
69 // --------------------------------------------------------- |
100 // CActiveApDbNotifier::Start |
70 // CActiveApDbNotifier::Start |
101 // --------------------------------------------------------- |
71 // --------------------------------------------------------- |
102 // |
72 // |
103 void CActiveApDbNotifier::Start() |
73 void CActiveApDbNotifier::Start() |
104 { |
74 { |
105 NotifyChange(); |
|
106 } |
75 } |
107 |
76 |
108 // --------------------------------------------------------- |
77 // --------------------------------------------------------- |
109 // CActiveApDbNotifier::NotifyChange |
78 // CActiveApDbNotifier::NotifyChange |
110 // --------------------------------------------------------- |
79 // --------------------------------------------------------- |
111 // |
80 // |
112 void CActiveApDbNotifier::NotifyChange() |
81 void CActiveApDbNotifier::NotifyChange() |
113 { |
82 { |
114 if ( !IsActive() ) |
|
115 { |
|
116 iActiveDb->Database()->RequestNotification( iStatus ); |
|
117 SetActive(); |
|
118 } |
|
119 } |
83 } |
120 |
84 |
121 // End of File |
85 // End of File |