1 /* |
|
2 * Copyright (c) 2002-2007 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: Provides notification service of changes in VoIP profiles. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <centralrepository.h> |
|
22 #include <featmgr.h> |
|
23 |
|
24 #include "crcsechangenotifier.h" |
|
25 #include "rcseconstants.h" |
|
26 #include "rcsebackupobserver.h" |
|
27 #include "rcselogger.h" |
|
28 #include "rcsepanic.h" |
|
29 #include "rcseprivatecrkeys.h" |
|
30 |
|
31 |
|
32 const TUint32 KUnknownNotifier = KMaxTUint; |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CRCSEChangeNotifier::CRCSEChangeNotifier |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CRCSEChangeNotifier::CRCSEChangeNotifier() |
|
43 { |
|
44 iRange = KUnknownNotifier; |
|
45 iNotifyRequested = EFalse; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CRCSEChangeNotifier::ConstructL |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CRCSEChangeNotifier::ConstructL( const TDesC& aName ) |
|
54 { |
|
55 RCSELOGSTRING( "CRCSEChangeNotifier::ConstructL() - IN" ); |
|
56 RCSELOGTHREAD(); |
|
57 |
|
58 // Check VoIP support from feature manager |
|
59 FeatureManager::InitializeLibL(); |
|
60 TBool support = FeatureManager::FeatureSupported( KFeatureIdCommonVoip ); |
|
61 FeatureManager::UnInitializeLib(); |
|
62 if (!support) |
|
63 { |
|
64 User::Leave(KErrNotSupported); |
|
65 } |
|
66 |
|
67 iRepository = CRepository::NewL( KCRUidRCSE ); |
|
68 |
|
69 iName.Copy( aName ); |
|
70 iBackupObserver = CRCSEBackupObserver::NewL( *this ); |
|
71 |
|
72 RCSELOGSTRING( "CRCSEChangeNotifier::ConstructL() - OUT" ); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CRCSEChangeNotifier::NewL |
|
77 // Two-phased constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C CRCSEChangeNotifier* CRCSEChangeNotifier::NewL( const TDesC& aName ) |
|
81 { |
|
82 CRCSEChangeNotifier* self = new( ELeave ) CRCSEChangeNotifier(); |
|
83 CleanupStack::PushL( self ); |
|
84 self->ConstructL( aName ); |
|
85 CleanupStack::Pop( self ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CRCSEChangeNotifier::~CRCSEChangeNotifier |
|
92 // Destructor. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C CRCSEChangeNotifier::~CRCSEChangeNotifier() |
|
96 { |
|
97 RCSELOGSTRING( "CRCSEChangeNotifier::~CRCSEChangeNotifier() - IN" ); |
|
98 RCSELOGTHREAD(); |
|
99 |
|
100 if ( iBackupObserver ) |
|
101 { |
|
102 iBackupObserver->Cancel(); |
|
103 delete iBackupObserver; |
|
104 iBackupObserver = NULL; |
|
105 } |
|
106 |
|
107 delete iRepository; |
|
108 |
|
109 RCSELOGSTRING( "CRCSEChangeNotifier::~CRCSEChangeNotifier() - OUT" ); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CRCSEChangeNotifier::HandleBackupOperationEventL |
|
114 // Handle backup events. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CRCSEChangeNotifier::HandleBackupOperationEventL() |
|
118 { |
|
119 RCSELOGSTRING( "CRCSEChangeNotifier::HandleBackupOperationEventL() - IN" ); |
|
120 RCSELOGTHREAD(); |
|
121 |
|
122 if ( iBackupObserver->IsBackupOperationRunning() ) |
|
123 { |
|
124 CancelNotify(); |
|
125 } |
|
126 else if ( iReqStatus ) |
|
127 { |
|
128 NotifyChange( *iReqStatus ); |
|
129 iReqStatus = NULL; |
|
130 } |
|
131 |
|
132 RCSELOGSTRING( "CRCSEChangeNotifier::HandleBackupOperationEventL() - OUT" ); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CRCSEChangeNotifier::NotifyChange |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C void CRCSEChangeNotifier::NotifyChange( TRequestStatus& aStatus ) |
|
140 { |
|
141 RCSELOGSTRING( "CRCSEChangeNotifier::NotifyChange() - IN" ); |
|
142 RCSELOGTHREAD(); |
|
143 |
|
144 // If backup is active, store request handle for later use. |
|
145 if ( iBackupObserver->IsBackupOperationRunning() ) |
|
146 { |
|
147 RCSELOGSTRING( "CRCSEChangeNotifier::NotifyChange() - BUR active" ); |
|
148 iReqStatus = &aStatus; |
|
149 aStatus = KRequestPending; |
|
150 } |
|
151 else |
|
152 { |
|
153 TRAP_IGNORE( SetNotifierL( aStatus ) ); |
|
154 } |
|
155 |
|
156 RCSELOGSTRING( "CRCSEChangeNotifier::NotifyChange() - OUT" ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CRCSEChangeNotifier::CancelNotify |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C void CRCSEChangeNotifier::CancelNotify() |
|
164 { |
|
165 RCSELOGSTRING( "CRCSEChangeNotifier::CancelNotify() - IN" ); |
|
166 RCSELOGTHREAD(); |
|
167 |
|
168 iRepository->NotifyCancel( iRange, KRCSEColumnMask ); |
|
169 iReqStatus = NULL; |
|
170 iNotifyRequested = EFalse; |
|
171 |
|
172 RCSELOGSTRING( "CRCSEChangeNotifier::CancelNotify() - OUT" ); |
|
173 } |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CRCSEChangeNotifier::SetNotifierL |
|
176 // Set up notifier to requested data source |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CRCSEChangeNotifier::SetNotifierL( TRequestStatus& aStatus ) |
|
180 { |
|
181 RCSELOGSTRING2( "CRCSEChangeNotifier::SetNotifierL( %S ) - IN", &iName ); |
|
182 |
|
183 if ( KDbName() == iName ) // VoIP profile IDs |
|
184 { |
|
185 iRange = KColProfileId; |
|
186 } |
|
187 else if ( KDbCodecName() == iName ) // Audio Codec IDs |
|
188 { |
|
189 iRange = KColAudioCodecId; |
|
190 } |
|
191 else // Unknown |
|
192 { |
|
193 User::Leave( KErrArgument ); |
|
194 } |
|
195 |
|
196 User::LeaveIfError( |
|
197 iRepository->NotifyRequest( iRange, KRCSEColumnMask, aStatus ) ); |
|
198 |
|
199 iNotifyRequested = ETrue; |
|
200 |
|
201 RCSELOGSTRING( "CRCSEChangeNotifier::SetNotifierL() - OUT" ); |
|
202 } |
|
203 |
|
204 |
|
205 // End of File |
|