|
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 CActiveScheduler::Add( this ); |
|
73 |
|
74 // Connect CenRep |
|
75 TRAPD( err, iRepository = CRepository::NewL( iRepositoryUid ) ); |
|
76 if( err != KErrNone ) |
|
77 { |
|
78 #ifdef USE_LOGGER |
|
79 MEWLOGGER_WRITE( "Error in connecting to CenRep!" ); |
|
80 #endif |
|
81 return; |
|
82 } |
|
83 |
|
84 #ifdef USE_LOGGER |
|
85 MEWLOGGER_WRITE( "Connected to CenRep CenRep!" ); |
|
86 #endif |
|
87 |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // Symbian two-phased constructor |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 CMsgCenRepObserver* CMsgCenRepObserver::NewL( CMsgErrorWatcher* aWatcher ) |
|
95 { |
|
96 CMsgCenRepObserver* self = new ( ELeave ) CMsgCenRepObserver( aWatcher ); |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL(); |
|
99 CleanupStack::Pop( self ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------- |
|
104 // Destructor |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 CMsgCenRepObserver::~CMsgCenRepObserver() |
|
108 { |
|
109 Cancel(); |
|
110 if( iRepository ) |
|
111 { |
|
112 delete iRepository; |
|
113 } |
|
114 |
|
115 #ifdef USE_LOGGER |
|
116 MEWLOGGER_WRITE( "CenRepObserver destroyed!" ); |
|
117 #endif |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // SubscribeNotification |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 void CMsgCenRepObserver::SubscribeNotification( ) |
|
125 { |
|
126 #ifdef USE_LOGGER |
|
127 MEWLOGGER_WRITE( "CMsgCenRepObserver::SubscribeNotification" ); |
|
128 #endif |
|
129 // Subscribe |
|
130 iRepository->NotifyRequest( iKey, iStatus ); |
|
131 SetActive(); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // RunL |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 void CMsgCenRepObserver::RunL() |
|
139 { |
|
140 #ifdef USE_LOGGER |
|
141 MEWLOGGER_WRITE( "CMsgCenRepObserver::RunL" ); |
|
142 #endif |
|
143 |
|
144 iWatcher -> HandleCenRepNotificationL(); |
|
145 } |
|
146 |
|
147 TInt CMsgCenRepObserver::RunError( TInt /*aError*/ ) |
|
148 { |
|
149 //In case RunL leaves |
|
150 #ifdef USE_LOGGER |
|
151 MEWLOGGER_WRITE( "CMsgCenRepObserver::RunError" ); |
|
152 #endif |
|
153 return KErrNone; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // DoCancel |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 void CMsgCenRepObserver::DoCancel() |
|
161 { |
|
162 #ifdef USE_LOGGER |
|
163 MEWLOGGER_WRITE( "CMsgCenRepObserver::DoCancel" ); |
|
164 #endif |
|
165 iRepository->NotifyCancel( iKey ); |
|
166 } |
|
167 |
|
168 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
169 |
|
170 // End of File |
|
171 |