|
1 /* |
|
2 * Copyright (c) 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: Implements the default plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "AspPreSyncDefaultPlugin.h" |
|
21 |
|
22 #include <ConeResLoader.h> |
|
23 #include <bautils.h> |
|
24 #include <eikenv.h> |
|
25 #include <AknGlobalNote.h> |
|
26 #include <StringLoader.h> |
|
27 #include <avkon.rsg> |
|
28 #include <avkon.hrh> |
|
29 #include <AknGlobalMsgQuery.h> |
|
30 #include <rconnmon.h> |
|
31 |
|
32 |
|
33 #include <AknQueryDialog.h> |
|
34 #include <AspSyncUtil.rsg> |
|
35 #include <StringLoader.h> |
|
36 #include <aspdefines.h> //For enum TRoamingSettings |
|
37 #include <centralrepository.h> //For central Repository |
|
38 |
|
39 // ============================== MEMBER FUNCTIONS ============================ |
|
40 |
|
41 _LIT(KDC_RESOURCE_FILES_DIR,"\\resource\\"); |
|
42 _LIT(KResourceFile, "z:AspSyncUtil.rsc"); |
|
43 |
|
44 |
|
45 // ------------------------------------------------------------------------------- |
|
46 // CRoamingCheck::NewL |
|
47 // |
|
48 // |
|
49 // ------------------------------------------------------------------------------- |
|
50 // |
|
51 CRoamingCheck* CRoamingCheck::NewL() |
|
52 { |
|
53 CRoamingCheck* self = CRoamingCheck::NewLC(); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ------------------------------------------------------------------------------- |
|
59 // CRoamingCheck::NewLC |
|
60 // |
|
61 // |
|
62 // ------------------------------------------------------------------------------- |
|
63 // |
|
64 CRoamingCheck* CRoamingCheck::NewLC() |
|
65 { |
|
66 CRoamingCheck* self = new (ELeave) CRoamingCheck(CEikonEnv::Static()); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ------------------------------------------------------------------------------- |
|
73 // CRoamingCheck::CRoamingCheck |
|
74 // |
|
75 // |
|
76 // ------------------------------------------------------------------------------- |
|
77 // |
|
78 CRoamingCheck::CRoamingCheck(CEikonEnv* aEikEnv) |
|
79 : iEnv(aEikEnv),iResLoader (*aEikEnv) |
|
80 { |
|
81 } |
|
82 |
|
83 // ------------------------------------------------------------------------------- |
|
84 // CRoamingCheck::~CRoamingCheck |
|
85 // |
|
86 // |
|
87 // ------------------------------------------------------------------------------- |
|
88 // |
|
89 CRoamingCheck::~CRoamingCheck() |
|
90 { |
|
91 iResLoader.Close(); |
|
92 delete iGlobalNote; |
|
93 |
|
94 } |
|
95 |
|
96 // ------------------------------------------------------------------------------- |
|
97 // CRoamingCheck::ConstructL |
|
98 // |
|
99 // |
|
100 // ------------------------------------------------------------------------------- |
|
101 // |
|
102 void CRoamingCheck::ConstructL() |
|
103 { |
|
104 iGlobalNote = CAknGlobalMsgQuery::NewL(); |
|
105 |
|
106 // Resolve resource file path |
|
107 TFileName fileName(0); |
|
108 TParse parse; |
|
109 parse.Set(KResourceFile,&KDC_RESOURCE_FILES_DIR,NULL); |
|
110 fileName.Append( parse.FullName() ); |
|
111 // Get language of resource file |
|
112 BaflUtils::NearestLanguageFile(iEnv->FsSession(), fileName ); |
|
113 // Open resource file |
|
114 TInt err = iResLoader.Open( fileName ); |
|
115 } |
|
116 |
|
117 // ------------------------------------------------------------------------------- |
|
118 // CRoamingCheck::ShowGlobalNoteL |
|
119 // |
|
120 // |
|
121 // ------------------------------------------------------------------------------- |
|
122 // |
|
123 void CRoamingCheck::ShowGlobalNoteL(TInt aSoftKeyId, |
|
124 const HBufC* aMessage, TInt& status) |
|
125 { |
|
126 iGlobalNote->CancelMsgQuery(); |
|
127 TRequestStatus GlobalNotestatus = KErrNone; |
|
128 iGlobalNote->ShowMsgQueryL( GlobalNotestatus, *aMessage, aSoftKeyId, KNullDesC , KNullDesC ); |
|
129 User::WaitForRequest(GlobalNotestatus); |
|
130 iGlobalNote->CancelMsgQuery(); |
|
131 status=GlobalNotestatus.Int(); |
|
132 } |
|
133 |
|
134 |
|
135 // ---------------------------------------------------------------------------- |
|
136 // CPreSyncDefaultPlugin::NewL |
|
137 // Two Phase Construction |
|
138 // ---------------------------------------------------------------------------- |
|
139 CPreSyncDefaultPlugin* CPreSyncDefaultPlugin::NewL() |
|
140 { |
|
141 CPreSyncDefaultPlugin* self = new ( ELeave ) CPreSyncDefaultPlugin(); |
|
142 CleanupStack::PushL( self ); |
|
143 self->ConstructL(); |
|
144 CleanupStack::Pop( self ); |
|
145 |
|
146 return self; |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------- |
|
150 // CPreSyncDefaultPlugin::CPreSyncDefaultPlugin |
|
151 // Two Phase Construction |
|
152 // ---------------------------------------------------------------------------- |
|
153 CPreSyncDefaultPlugin::CPreSyncDefaultPlugin() |
|
154 { |
|
155 } |
|
156 |
|
157 // ---------------------------------------------------------------------------- |
|
158 // CPreSyncDefaultPlugin::ConstructL |
|
159 // Two Phase Construction |
|
160 // ---------------------------------------------------------------------------- |
|
161 void CPreSyncDefaultPlugin::ConstructL() |
|
162 { |
|
163 } |
|
164 |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CPreSyncDefaultPlugin::~CPreSyncDefaultPlugin |
|
168 // Destructor |
|
169 // ---------------------------------------------------------------------------- |
|
170 CPreSyncDefaultPlugin::~CPreSyncDefaultPlugin() |
|
171 { |
|
172 } |
|
173 |
|
174 |
|
175 // ------------------------------------------------------------------------------- |
|
176 // CPreSyncDefaultPlugin::IsSupported |
|
177 // |
|
178 // |
|
179 // ------------------------------------------------------------------------------- |
|
180 // |
|
181 TBool CPreSyncDefaultPlugin::IsSupported() |
|
182 { |
|
183 return ETrue; |
|
184 } |
|
185 |
|
186 // ------------------------------------------------------------------------------- |
|
187 // CPreSyncDefaultPlugin::CanSyncL |
|
188 // |
|
189 // |
|
190 // ------------------------------------------------------------------------------- |
|
191 // |
|
192 TBool CPreSyncDefaultPlugin::CanSyncL() |
|
193 { |
|
194 TBool ret = ETrue; |
|
195 TInt value(0); |
|
196 |
|
197 ReadRepositoryL(KNSmlRoamingSettingKey, value); |
|
198 CRoamingCheck* roamingCheck = CRoamingCheck::NewL(); |
|
199 CleanupStack::PushL(roamingCheck); |
|
200 |
|
201 HBufC* hBuf = NULL; |
|
202 CAknQueryDialog* queryDialog = NULL; |
|
203 |
|
204 switch(value) |
|
205 { |
|
206 case ERoamingSettingAlwaysAsk: |
|
207 hBuf = StringLoader::LoadLC(R_ASP_NOTE_NETWORK_CONFIRMATION); |
|
208 queryDialog = new (ELeave) CAknQueryDialog; |
|
209 ret = queryDialog->ExecuteLD(R_ASP_ROAMING_CONFIRMATION_QUERY, hBuf->Des()); |
|
210 if(ret) |
|
211 { |
|
212 ret = ETrue; |
|
213 } |
|
214 else |
|
215 { |
|
216 ret = EFalse; |
|
217 } |
|
218 CleanupStack::PopAndDestroy(hBuf); |
|
219 break; |
|
220 case ERoamingSettingAlwaysAllow: |
|
221 break; |
|
222 case ERoamingSettingNeverAllow: |
|
223 hBuf = StringLoader::LoadLC(R_ASP_NOTE_NETWORK_NOT_ALLOWED); |
|
224 queryDialog = new (ELeave) CAknQueryDialog; |
|
225 ret = queryDialog->ExecuteLD(R_ASP_INFORMATION_QUERY, hBuf->Des()); |
|
226 CleanupStack::PopAndDestroy(hBuf); |
|
227 |
|
228 ret = EFalse; |
|
229 break; |
|
230 case ERoamingSettingBlock: |
|
231 hBuf = StringLoader::LoadLC(R_ASP_NOTE_NOT_HOME_NETWORK); |
|
232 queryDialog = new (ELeave) CAknQueryDialog; |
|
233 ret = queryDialog->ExecuteLD(R_ASP_INFORMATION_QUERY, hBuf->Des()); |
|
234 CleanupStack::PopAndDestroy(hBuf); |
|
235 |
|
236 ret = EFalse; |
|
237 break; |
|
238 default: |
|
239 break; |
|
240 } |
|
241 |
|
242 CleanupStack::PopAndDestroy(roamingCheck); |
|
243 return ret; |
|
244 } |
|
245 |
|
246 // ------------------------------------------------------------------------------- |
|
247 // CPreSyncDefaultPlugin::ReadRepositoryL |
|
248 // |
|
249 // |
|
250 // ------------------------------------------------------------------------------- |
|
251 // |
|
252 void CPreSyncDefaultPlugin::ReadRepositoryL(TInt aKey, TInt& aValue) |
|
253 { |
|
254 CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp); |
|
255 TInt err = rep->Get(aKey, aValue); |
|
256 User::LeaveIfError(err); |
|
257 |
|
258 CleanupStack::PopAndDestroy(rep); |
|
259 } |
|
260 |
|
261 |
|
262 // ------------------------------------------------------------------------------- |
|
263 // CPreSyncDefaultPlugin::SetProfile |
|
264 // |
|
265 // |
|
266 // ------------------------------------------------------------------------------- |
|
267 // |
|
268 TBool CPreSyncDefaultPlugin::SetProfile(const TSmlProfileId& aProfileId) |
|
269 { |
|
270 iSyncProfileId = aProfileId; |
|
271 return ETrue; |
|
272 } |
|
273 |
|
274 // ------------------------------------------------------------------------------- |
|
275 // CPreSyncDefaultPlugin::SyncNow |
|
276 // |
|
277 // |
|
278 // ------------------------------------------------------------------------------- |
|
279 // |
|
280 TInt CPreSyncDefaultPlugin::SyncNow(MSyncExtObserver* aObserver) |
|
281 { |
|
282 TInt retValue = 1; |
|
283 return retValue; |
|
284 } |
|
285 |
|
286 |