|
1 /* |
|
2 * Copyright (c) 2004 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 * CMsgCenRepObserver implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 //#include <es_sock.h> |
|
23 #include <centralrepository.h> |
|
24 |
|
25 #include "MsgErrorWatcher.h" |
|
26 #include "MsgCenRepObserver.h" |
|
27 |
|
28 #include "MmsEngineInternalCRKeys.h" |
|
29 |
|
30 #ifdef USE_LOGGER |
|
31 #include "MsgErrorWatcherLogging.h" |
|
32 #endif |
|
33 // EXTERNAL DATA STRUCTURES |
|
34 |
|
35 // EXTERNAL FUNCTION PROTOTYPES |
|
36 |
|
37 // CONSTANTS |
|
38 |
|
39 // MACROS |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 |
|
47 // ==================== LOCAL FUNCTIONS ==================== |
|
48 |
|
49 // ================= MEMBER FUNCTIONS ======================= |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // C++ constructor |
|
53 // --------------------------------------------------------- |
|
54 // |
|
55 CMsgCenRepObserver::CMsgCenRepObserver(CMsgErrorWatcher* aWatcher) |
|
56 :CActive ( EPriorityStandard), |
|
57 iWatcher( aWatcher ), |
|
58 iRepositoryUid( KCRUidMmsEngine ), |
|
59 iKey( KMmsAccesspointArrayBase/*KMmsEngineAccessPointCount*/ ) |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // ConstructL |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 void CMsgCenRepObserver::ConstructL() |
|
68 { |
|
69 #ifdef USE_LOGGER |
|
70 MEWLOGGER_WRITE( "CMsgCenRepObserver::ConstructL(" ); |
|
71 #endif |
|
72 |
|
73 // Connect CenRep |
|
74 TRAPD( err, iRepository = CRepository::NewL( iRepositoryUid ) ); |
|
75 if( err != KErrNone ) |
|
76 { |
|
77 #ifdef USE_LOGGER |
|
78 MEWLOGGER_WRITE( "Error in connecting to CenRep!" ); |
|
79 #endif |
|
80 return; |
|
81 } |
|
82 |
|
83 CActiveScheduler::Add(this); |
|
84 |
|
85 #ifdef USE_LOGGER |
|
86 MEWLOGGER_WRITE( "Connected to CenRep CenRep!" ); |
|
87 #endif |
|
88 |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------- |
|
92 // Symbian two-phased constructor |
|
93 // --------------------------------------------------------- |
|
94 // |
|
95 CMsgCenRepObserver* CMsgCenRepObserver::NewL( CMsgErrorWatcher* aWatcher ) |
|
96 { |
|
97 CMsgCenRepObserver* self = new ( ELeave ) CMsgCenRepObserver( aWatcher ); |
|
98 CleanupStack::PushL( self ); |
|
99 self->ConstructL(); |
|
100 CleanupStack::Pop( self ); |
|
101 return self; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // Destructor |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 CMsgCenRepObserver::~CMsgCenRepObserver() |
|
109 { |
|
110 Cancel(); |
|
111 if( iRepository ) |
|
112 { |
|
113 delete iRepository; |
|
114 } |
|
115 |
|
116 #ifdef USE_LOGGER |
|
117 MEWLOGGER_WRITE( "CenRepObserver destroyed!" ); |
|
118 #endif |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // SubscribeNotification |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 void CMsgCenRepObserver::SubscribeNotification( ) |
|
126 { |
|
127 #ifdef USE_LOGGER |
|
128 MEWLOGGER_WRITE( "CMsgCenRepObserver::SubscribeNotification" ); |
|
129 #endif |
|
130 // Subscribe |
|
131 if (iRepository) |
|
132 { |
|
133 TInt err = iRepository->NotifyRequest(iKey, iStatus); |
|
134 |
|
135 if (err == KErrNone) |
|
136 { |
|
137 SetActive(); |
|
138 } |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // RunL |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CMsgCenRepObserver::RunL() |
|
147 { |
|
148 #ifdef USE_LOGGER |
|
149 MEWLOGGER_WRITE( "CMsgCenRepObserver::RunL" ); |
|
150 #endif |
|
151 |
|
152 iWatcher -> HandleCenRepNotificationL(); |
|
153 } |
|
154 |
|
155 TInt CMsgCenRepObserver::RunError( TInt /*aError*/ ) |
|
156 { |
|
157 //In case RunL leaves |
|
158 #ifdef USE_LOGGER |
|
159 MEWLOGGER_WRITE( "CMsgCenRepObserver::RunError" ); |
|
160 #endif |
|
161 return KErrNone; |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // DoCancel |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CMsgCenRepObserver::DoCancel() |
|
169 { |
|
170 #ifdef USE_LOGGER |
|
171 MEWLOGGER_WRITE( "CMsgCenRepObserver::DoCancel" ); |
|
172 #endif |
|
173 iRepository->NotifyCancel( iKey ); |
|
174 } |
|
175 |
|
176 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
177 |
|
178 // End of File |
|
179 |