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