|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * CMsgErrorCommDbObserver implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <commdb.h> |
|
24 |
|
25 #include "MsgErrorWatcher.h" |
|
26 #include "MsgErrorCommDbObserver.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // CMsgErrorCommDbObserver::CMsgErrorCommDbObserver |
|
32 // |
|
33 // C++ constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 CMsgErrorCommDbObserver::CMsgErrorCommDbObserver( CMsgErrorWatcher* aWatcher ) |
|
38 : CActive( CActive::EPriorityStandard ), |
|
39 iWatcher( aWatcher ) |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------- |
|
44 // CMsgErrorCommDbObserver::ConstructL |
|
45 // |
|
46 // Symbian OS default constructor can leave. |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 void CMsgErrorCommDbObserver::ConstructL() |
|
50 { |
|
51 iDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
52 CActiveScheduler::Add( this ); |
|
53 Start(); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CMsgErrorCommDbObserver::NewL |
|
58 // |
|
59 // Two-phased constructor. |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 CMsgErrorCommDbObserver* CMsgErrorCommDbObserver::NewL( CMsgErrorWatcher* aWatcher ) |
|
63 { |
|
64 CMsgErrorCommDbObserver* self = new ( ELeave ) |
|
65 CMsgErrorCommDbObserver( aWatcher ); |
|
66 |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CMsgErrorCommDbObserver::~CMsgErrorCommDbObserver |
|
77 // |
|
78 // Destructor |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 CMsgErrorCommDbObserver::~CMsgErrorCommDbObserver() |
|
82 { |
|
83 Cancel(); |
|
84 delete iDb; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CMsgErrorCommDbObserver::Restart |
|
89 // |
|
90 // (Re)starts the active object (public) |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 void CMsgErrorCommDbObserver::Restart() |
|
94 { |
|
95 Start(); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CMsgErrorCommDbObserver::Start |
|
100 // |
|
101 // Starts the active object |
|
102 // --------------------------------------------------------- |
|
103 // |
|
104 void CMsgErrorCommDbObserver::Start() |
|
105 { |
|
106 if ( !IsActive() ) |
|
107 { |
|
108 iDb->RequestNotification( iStatus ); |
|
109 SetActive(); |
|
110 } |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------- |
|
114 // CMsgErrorCommDbObserver::DoCancel |
|
115 // |
|
116 // From active object framework |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 void CMsgErrorCommDbObserver::DoCancel() |
|
120 { |
|
121 if ( iDb ) |
|
122 { |
|
123 iDb->CancelRequestNotification(); |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CMsgErrorCommDbObserver::RunL |
|
129 // |
|
130 // From active object framework |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CMsgErrorCommDbObserver::RunL() |
|
134 { |
|
135 if ( iStatus == RDbNotifier::ECommit ) |
|
136 { |
|
137 TRAP_IGNORE( iWatcher->HandleCommDbEventL() ); |
|
138 } |
|
139 else |
|
140 { |
|
141 Start(); |
|
142 } |
|
143 } |
|
144 |
|
145 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
146 |
|
147 // End of File |