|
1 /* |
|
2 * Copyright (c) 2004-2005 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: Persistent preference store variation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Include Files |
|
20 #include "CCASDCRVariator.h" |
|
21 #include "MCASettings.h" |
|
22 #include "imnginternalcrkeys.h" |
|
23 #include "IMPrivateCRKeys.h" |
|
24 #include "IMInternalPSKeys.h" |
|
25 #include "ChatDebugPrint.h" |
|
26 |
|
27 #include <e32property.h> |
|
28 #include <centralrepository.h> |
|
29 |
|
30 _LIT_SECURITY_POLICY_S0( KIMWritePolicy, 0x101F4673 ); |
|
31 _LIT_SECURITY_POLICY_S0( KIMReadPolicy, 0x101F4673 ); |
|
32 |
|
33 // CONSTRUCTION |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CCASDCRVariator::NewL |
|
37 // Static constructor. Identifier ignored with central repository. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CCASDCRVariator* CCASDCRVariator::NewL( TUid aIdentifier ) |
|
41 { |
|
42 CCASDCRVariator* self = new ( ELeave ) CCASDCRVariator; |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aIdentifier ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CCASDCRVariator::~CCASDCRVariator |
|
51 // Destructor (virtual by CBase) |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CCASDCRVariator::~CCASDCRVariator() |
|
55 { |
|
56 CHAT_DP_FUNC_ENTER( "~CCASDCRVariator" ); |
|
57 delete iCenRep; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CCASDCRVariator::ConstructL |
|
62 // Second phase construct |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CCASDCRVariator::ConstructL( TUid /* aIdentifier */ ) |
|
66 { |
|
67 CHAT_DP_FUNC_ENTER( "ConstructL - Central repository" ); |
|
68 iCenRep = CRepository::NewL( KCRUidIM ); |
|
69 CHAT_DP_FUNC_DONE( "ConstructL" ); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CCASDCRVariator::CCASDCRVariator |
|
74 // Constructor |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CCASDCRVariator::CCASDCRVariator() |
|
78 { |
|
79 // empty |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CCASDCRVariator::GetInt |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TInt CCASDCRVariator::GetInt( TInt aSetting, TInt& aValue ) |
|
87 { |
|
88 CHAT_DP_FUNC_ENTER( "GetInt" ); |
|
89 TInt key = GenerateKey( aSetting ); |
|
90 return iCenRep->Get( key, aValue ); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CCASDCRVariator::SetInt |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CCASDCRVariator::SetInt( TInt aSetting, TInt aValue ) |
|
98 { |
|
99 CHAT_DP_FUNC_ENTER( "SetInt" ); |
|
100 TInt key = GenerateKey( aSetting ); |
|
101 return iCenRep->Set( key, aValue ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CCASDCRVariator::FlushData |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 TInt CCASDCRVariator::FlushData() |
|
109 { |
|
110 CHAT_DP_FUNC_ENTER( "FlushData" ); |
|
111 // in central repository the data is written immediately, |
|
112 // no need to flush |
|
113 return KErrNone; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CCASDCRVariator::GetString |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TInt CCASDCRVariator::GetString( TInt aSetting, TDes& aValue ) |
|
121 { |
|
122 CHAT_DP_FUNC_ENTER( "GetString" ); |
|
123 TInt key = GenerateKey( aSetting ); |
|
124 |
|
125 switch ( aSetting ) |
|
126 { |
|
127 case MCASettings::EServiceAddress: |
|
128 { |
|
129 return RProperty::Get( KPSUidIMEngine, KIMServiceAddress, aValue ); |
|
130 } |
|
131 default: |
|
132 { |
|
133 return iCenRep->Get( key, aValue ); |
|
134 } |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CCASDCRVariator::SetString |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CCASDCRVariator::SetString( TInt aSetting, const TDesC& aValue ) |
|
143 { |
|
144 CHAT_DP_FUNC_ENTER( "SetString" ); |
|
145 TInt key = GenerateKey( aSetting ); |
|
146 |
|
147 switch ( aSetting ) |
|
148 { |
|
149 case MCASettings::EServiceAddress: |
|
150 { |
|
151 RProperty::Define( KPSUidIMEngine, KIMServiceAddress, |
|
152 RProperty::EText, KIMReadPolicy, KIMWritePolicy ); |
|
153 return RProperty::Set( KPSUidIMEngine, KIMServiceAddress, aValue ); |
|
154 } |
|
155 default: |
|
156 { |
|
157 return iCenRep->Set( key, aValue ); |
|
158 } |
|
159 } |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // CCASDCRVariator::GenerateKey |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 TInt CCASDCRVariator::GenerateKey( const TInt aSettingNumber ) const |
|
167 { |
|
168 CHAT_DP_FUNC_ENTER( "GenerateKey" ); |
|
169 // we could use a table but this is just as fast, if not |
|
170 // faster. consider it an unrolled loop. e.g. we can't use |
|
171 // the aSettingNumber as index, since the enumerations |
|
172 // are not consecutive and have different bases where they start |
|
173 switch ( aSettingNumber ) |
|
174 { |
|
175 case MCASettings::EFirstLoginDone : |
|
176 return KIMFirstLogin; |
|
177 |
|
178 case MCASettings::EDefaultScreenNameInUse : |
|
179 return KIMScreenNameInUse; |
|
180 |
|
181 case MCASettings::EAutomaticPresenceUpdate : |
|
182 return KIMAutoPresence; |
|
183 |
|
184 case MCASettings::EShowHistory : |
|
185 return KIMShowHistory; |
|
186 |
|
187 case MCASettings::EAuthorizeIMPresence : |
|
188 return KIMAuthPresence; |
|
189 |
|
190 case MCASettings::EReceiveIMessages : |
|
191 return KIMAuthIM; |
|
192 |
|
193 case MCASettings::EReceiveInvitations : |
|
194 return KIMAuthInvite; |
|
195 |
|
196 case MCASettings::EMessageFlowSettingLevel : |
|
197 return KIMMsgFlow; |
|
198 |
|
199 case MCASettings::EFriendsListOrdering : |
|
200 return KIMOrderFriends; |
|
201 |
|
202 case MCASettings::EDefaultScreenName : |
|
203 return KIMDefScreenName; |
|
204 |
|
205 case MCASettings::EOwnWVUserID : |
|
206 return KIMOwnUserId; |
|
207 |
|
208 case MCASettings::EOwnAlias : |
|
209 return KIMAliasName; |
|
210 |
|
211 case MCASettings::EServiceAddress : |
|
212 return KIMServiceAddress; |
|
213 |
|
214 case MCASettings::EShowOffline : |
|
215 return KIMOfflineContacts; |
|
216 |
|
217 case MCASettings::EStatusMsgOnline: |
|
218 return KIMStatusMsgOnline; |
|
219 |
|
220 case MCASettings::EStatusMsgAway: |
|
221 return KIMStatusMsgAway; |
|
222 |
|
223 case MCASettings::EStatusMsgBusy: |
|
224 return KIMStatusMsgBusy; |
|
225 default: |
|
226 break; |
|
227 } |
|
228 |
|
229 return -1; |
|
230 } |
|
231 |
|
232 |
|
233 // End of File |