|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Listen connect screen id key changes in central repository. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <centralrepository.h> |
|
20 #include <mpmconnectscreenid.h> |
|
21 #include <featmgr.h> // FeatureManager |
|
22 #include "mpmcsidwatcher.h" |
|
23 #include "mpmlogger.h" |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Default constructor |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CMpmCsIdWatcher::CMpmCsIdWatcher() |
|
30 : CActive( EPriorityStandard ) |
|
31 { |
|
32 CActiveScheduler::Add( this ); |
|
33 } |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Creates central repositor object |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 void CMpmCsIdWatcher::ConstructL() |
|
41 { |
|
42 iRepository = CRepository::NewL( KMpmOccCenRepUid ); |
|
43 |
|
44 // Check whether user connection is supported |
|
45 FeatureManager::InitializeLibL(); |
|
46 iUserConnectionSupported = FeatureManager::FeatureSupported( |
|
47 KFeatureIdFfConnectionOverride ); |
|
48 |
|
49 FeatureManager::UnInitializeLib(); |
|
50 } |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // Creates new object |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CMpmCsIdWatcher* CMpmCsIdWatcher::NewL() |
|
58 { |
|
59 CMpmCsIdWatcher* self = new( ELeave ) CMpmCsIdWatcher(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // Destructor |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CMpmCsIdWatcher::~CMpmCsIdWatcher() |
|
71 { |
|
72 Cancel(); |
|
73 delete iRepository; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Order notification from changes |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CMpmCsIdWatcher::StartL() |
|
81 { |
|
82 // Request notification |
|
83 User::LeaveIfError( iRepository->NotifyRequest( KMpmConnectScreenId, |
|
84 iStatus )); |
|
85 SetActive(); |
|
86 |
|
87 // Get value from central repository |
|
88 User::LeaveIfError(iRepository->Get(KMpmConnectScreenId, iConnectScreenId)); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Return connect screen id |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 TUint32 CMpmCsIdWatcher::ConnectScreenId() const |
|
96 { |
|
97 if ( iUserConnectionSupported ) |
|
98 { |
|
99 // Return real value if user connection is supported |
|
100 return iConnectScreenId; |
|
101 } |
|
102 else |
|
103 { |
|
104 // Return 0xFFFFFFFF if user connection is not supported |
|
105 return 0xFFFFFFFF; |
|
106 } |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // From class CActive. |
|
111 // When there is a change in central repository key, event is received in here |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CMpmCsIdWatcher::RunL() |
|
115 { |
|
116 // Leave if error |
|
117 User::LeaveIfError( iStatus.Int() ); |
|
118 |
|
119 // Request new notification |
|
120 User::LeaveIfError( iRepository->NotifyRequest( KMpmConnectScreenId, |
|
121 iStatus )); |
|
122 SetActive(); |
|
123 |
|
124 // Get value from central repository |
|
125 iRepository->Get( KMpmConnectScreenId, iConnectScreenId ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // From class CActive. |
|
130 // Nothing to do over here |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 TInt CMpmCsIdWatcher::RunError( TInt /*aError*/ ) |
|
134 { |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // From class CActive. |
|
140 // Cancel outstanding request |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CMpmCsIdWatcher::DoCancel() |
|
144 { |
|
145 iRepository->NotifyCancel( KMpmConnectScreenId ); |
|
146 } |
|
147 |