1 /* |
|
2 * Copyright (c) 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: This provides the messaging mw interface for MMS |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <commdb.h> |
|
19 #include <commdbconnpref.h> |
|
20 #include <msvapi.h> |
|
21 #include <msvstd.h> |
|
22 #include <msvuids.h> |
|
23 #include <mmsaccount.h> |
|
24 #include <mmssettings.h> |
|
25 #include "debugtraces.h" |
|
26 |
|
27 |
|
28 #include "mmssettingprivate.h" |
|
29 |
|
30 /** |
|
31 * Message Server session event handler |
|
32 */ |
|
33 class CEventHandler : public MMsvSessionObserver |
|
34 { |
|
35 public: |
|
36 void HandleSessionEvent(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, |
|
37 TAny* aArg3); |
|
38 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, |
|
39 TAny* aArg3); |
|
40 }; |
|
41 void CEventHandler::HandleSessionEvent(TMsvSessionEvent /*aEvent*/, |
|
42 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
43 { |
|
44 } |
|
45 void CEventHandler::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
46 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
47 { |
|
48 } |
|
49 |
|
50 //two phase constructor |
|
51 MmsSettingsPrivate* MmsSettingsPrivate::NewL() |
|
52 { |
|
53 MmsSettingsPrivate* self = new (ELeave) MmsSettingsPrivate(); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 //--------------------------------------------------------------- |
|
61 // MmsSettingsPrivate::MmsSettingsPrivate |
|
62 // @see header |
|
63 //--------------------------------------------------------------- |
|
64 MmsSettingsPrivate::MmsSettingsPrivate() |
|
65 { |
|
66 //do nothing |
|
67 } |
|
68 |
|
69 //2nd phase constructor |
|
70 void MmsSettingsPrivate::ConstructL() |
|
71 { |
|
72 //for debug only |
|
73 //createRepositoryL(); |
|
74 } |
|
75 |
|
76 //--------------------------------------------------------------- |
|
77 // MmsSettingsPrivate::~MmsSettingsPrivate |
|
78 // @see header |
|
79 //--------------------------------------------------------------- |
|
80 MmsSettingsPrivate::~MmsSettingsPrivate() |
|
81 { |
|
82 // do nothing |
|
83 } |
|
84 |
|
85 //--------------------------------------------------------------- |
|
86 // MmsSettingsPrivate::createRepository |
|
87 // @see header |
|
88 //--------------------------------------------------------------- |
|
89 void MmsSettingsPrivate::createRepositoryL() |
|
90 { |
|
91 CEventHandler* pObserver = new (ELeave) CEventHandler(); |
|
92 CleanupStack::PushL(pObserver); |
|
93 |
|
94 CMsvSession* iMsvSession = CMsvSession::OpenSyncL(*pObserver); |
|
95 CleanupStack::PushL(iMsvSession); |
|
96 |
|
97 CMmsSettings* mmsSetting = CMmsSettings::NewL(); |
|
98 CleanupStack::PushL(mmsSetting); |
|
99 |
|
100 mmsSetting->LoadSettingsL(); |
|
101 |
|
102 TMsvId entryToBeKilled = KMsvNullIndexEntryId; |
|
103 // Get access to root index |
|
104 CMsvEntry* cEntry = iMsvSession->GetEntryL(KMsvRootIndexEntryId); |
|
105 CleanupStack::PushL(cEntry); |
|
106 |
|
107 entryToBeKilled = mmsSetting->Service(); |
|
108 cEntry->SetSortTypeL(TMsvSelectionOrdering(KMsvNoGrouping, |
|
109 EMsvSortByNone, |
|
110 ETrue)); |
|
111 if (entryToBeKilled == KMsvNullIndexEntryId) |
|
112 { |
|
113 mmsSetting->CreateNewServiceL(*iMsvSession); |
|
114 } |
|
115 |
|
116 CleanupStack::PopAndDestroy(); // cEntry |
|
117 |
|
118 mmsSetting->SetReceivingModeHome(EMmsReceivingAutomatic); |
|
119 mmsSetting->SetReceivingModeForeign(EMmsReceivingAutomatic); |
|
120 |
|
121 mmsSetting->SaveSettingsL(); |
|
122 |
|
123 CleanupStack::PopAndDestroy(3); // settings |
|
124 } |
|
125 |
|
126 void MmsSettingsPrivate::setDeliveryReport(TBool aReport) |
|
127 { |
|
128 CMmsAccount* mmsAccount = CMmsAccount::NewL(); |
|
129 CleanupStack::PushL(mmsAccount); |
|
130 |
|
131 CMmsSettings* mmsSetting = CMmsSettings::NewL(); |
|
132 CleanupStack::PushL(mmsSetting); |
|
133 |
|
134 mmsAccount->LoadSettingsL(*mmsSetting); |
|
135 |
|
136 if (aReport) |
|
137 { |
|
138 mmsSetting->SetDeliveryReportWanted(KMmsYes); |
|
139 } |
|
140 else |
|
141 { |
|
142 mmsSetting->SetDeliveryReportWanted(KMmsNo); |
|
143 } |
|
144 |
|
145 //save the settings |
|
146 mmsAccount->SaveSettingsL(*mmsSetting); |
|
147 CleanupStack::PopAndDestroy(2); |
|
148 } |
|
149 |
|
150 void MmsSettingsPrivate::setCharacterEncoding(TBool /*aFlag*/) |
|
151 { |
|
152 //not provided |
|
153 } |
|
154 |
|
155 void MmsSettingsPrivate::settingsDeliverReportAndCharEncoding(TBool& aReport, |
|
156 TBool& aFlag) |
|
157 { |
|
158 CMmsAccount* mmsAccount = CMmsAccount::NewL(); |
|
159 CleanupStack::PushL(mmsAccount); |
|
160 |
|
161 CMmsSettings* mmsSetting = CMmsSettings::NewL(); |
|
162 CleanupStack::PushL(mmsSetting); |
|
163 |
|
164 mmsAccount->LoadSettingsL(*mmsSetting); |
|
165 |
|
166 TInt reportWanted = mmsSetting->DeliveryReportWanted(); |
|
167 aReport = EFalse; |
|
168 if (KMmsYes == reportWanted) |
|
169 { |
|
170 aReport = ETrue; |
|
171 } |
|
172 |
|
173 //set the aFlag as true by default |
|
174 aFlag = ETrue; |
|
175 |
|
176 CleanupStack::PopAndDestroy(2); |
|
177 } |
|
178 |
|
179 void MmsSettingsPrivate::setMMSCreationmode(MsgSettingEngine::MmsCreationMode aMode) |
|
180 { |
|
181 CMmsAccount* mMmsAccount = CMmsAccount::NewL(); |
|
182 CleanupStack::PushL(mMmsAccount); |
|
183 |
|
184 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
185 CleanupStack::PushL(mMmsSetting); |
|
186 |
|
187 mMmsAccount->LoadSettingsL(*mMmsSetting); |
|
188 |
|
189 TMmsCreationMode creationMode = EMmsCreationModeWarning; |
|
190 |
|
191 if (aMode == MsgSettingEngine::Restricted) |
|
192 creationMode = EMmsCreationModeRestricted; |
|
193 else if (aMode == MsgSettingEngine::Free) |
|
194 creationMode = EMmsCreationModeFree; |
|
195 |
|
196 mMmsSetting->SetCreationMode(creationMode); |
|
197 |
|
198 //save the settings |
|
199 mMmsAccount->SaveSettingsL(*mMmsSetting); |
|
200 CleanupStack::PopAndDestroy(2); |
|
201 } |
|
202 |
|
203 void MmsSettingsPrivate::setMMSRetrieval(MsgSettingEngine::MmsRetrieval aRetrieval) |
|
204 { |
|
205 CMmsAccount* mMmsAccount = CMmsAccount::NewL(); |
|
206 CleanupStack::PushL(mMmsAccount); |
|
207 |
|
208 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
209 CleanupStack::PushL(mMmsSetting); |
|
210 |
|
211 mMmsAccount->LoadSettingsL(*mMmsSetting); |
|
212 |
|
213 //do your operation |
|
214 TMmsReceivingMode receveMode = EMmsReceivingAutomatic; |
|
215 |
|
216 if (aRetrieval == MsgSettingEngine::Maual) |
|
217 receveMode = EMmsReceivingManual; |
|
218 else if (aRetrieval == MsgSettingEngine::Off) |
|
219 receveMode = EMmsReceivingPostpone; |
|
220 else if (aRetrieval == MsgSettingEngine::No) |
|
221 receveMode = EMmsReceivingReject; |
|
222 |
|
223 if (aRetrieval == MsgSettingEngine::AlwaysAutomatic) |
|
224 { |
|
225 mMmsSetting->SetReceivingModeForeign(receveMode); |
|
226 } |
|
227 else |
|
228 { |
|
229 mMmsSetting->SetReceivingModeForeign(EMmsReceivingManual); |
|
230 } |
|
231 |
|
232 mMmsSetting->SetReceivingModeHome(receveMode); |
|
233 |
|
234 //save the settings |
|
235 mMmsAccount->SaveSettingsL(*mMmsSetting); |
|
236 CleanupStack::PopAndDestroy(2); |
|
237 } |
|
238 |
|
239 void MmsSettingsPrivate::setAnonymousMessages(TBool aAnonymous) |
|
240 { |
|
241 CMmsAccount* mMmsAccount = CMmsAccount::NewL(); |
|
242 CleanupStack::PushL(mMmsAccount); |
|
243 |
|
244 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
245 CleanupStack::PushL(mMmsSetting); |
|
246 |
|
247 mMmsAccount->LoadSettingsL(*mMmsSetting); |
|
248 |
|
249 //do your operation |
|
250 mMmsSetting->SetAcceptAnonymousMessages(aAnonymous); |
|
251 |
|
252 //save the settings |
|
253 mMmsAccount->SaveSettingsL(*mMmsSetting); |
|
254 CleanupStack::PopAndDestroy(2); |
|
255 } |
|
256 |
|
257 void MmsSettingsPrivate::setReceiveMMSAdverts(TBool aReceiveAdvert) |
|
258 { |
|
259 CMmsAccount* mMmsAccount = CMmsAccount::NewL(); |
|
260 CleanupStack::PushL(mMmsAccount); |
|
261 |
|
262 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
263 CleanupStack::PushL(mMmsSetting); |
|
264 |
|
265 mMmsAccount->LoadSettingsL(*mMmsSetting); |
|
266 |
|
267 //do your operation |
|
268 mMmsSetting->SetAcceptAdvertisementMessages(aReceiveAdvert); |
|
269 |
|
270 //save the settings |
|
271 mMmsAccount->SaveSettingsL(*mMmsSetting); |
|
272 CleanupStack::PopAndDestroy(2); |
|
273 } |
|
274 |
|
275 void MmsSettingsPrivate::advanceMmsSettings( |
|
276 MsgSettingEngine::MmsCreationMode& aMode, |
|
277 MsgSettingEngine::MmsRetrieval& aRetrieval, |
|
278 TBool& aAnonymousStatus, |
|
279 TBool& aMmsAdvertsStatus) |
|
280 { |
|
281 CMmsAccount* mMmsAccount = CMmsAccount::NewL(); |
|
282 CleanupStack::PushL(mMmsAccount); |
|
283 |
|
284 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
285 CleanupStack::PushL(mMmsSetting); |
|
286 |
|
287 mMmsAccount->LoadSettingsL(*mMmsSetting); |
|
288 |
|
289 //do your operation |
|
290 TInt32 creationMode = mMmsSetting->CreationMode(); |
|
291 |
|
292 if (creationMode == EMmsCreationModeRestricted) |
|
293 { |
|
294 aMode = MsgSettingEngine::Restricted; |
|
295 } |
|
296 else if (creationMode == EMmsCreationModeFree) |
|
297 { |
|
298 aMode = MsgSettingEngine::Free; |
|
299 } |
|
300 |
|
301 TMmsReceivingMode receveMode = mMmsSetting->ReceivingModeHome(); |
|
302 |
|
303 if (receveMode == EMmsReceivingManual) |
|
304 aRetrieval = MsgSettingEngine::Maual; |
|
305 else if (receveMode == EMmsReceivingPostpone) |
|
306 aRetrieval = MsgSettingEngine::Off; |
|
307 else if (receveMode == EMmsReceivingReject) |
|
308 aRetrieval = MsgSettingEngine::No; |
|
309 |
|
310 receveMode = mMmsSetting->ReceivingModeForeign(); |
|
311 if (receveMode == EMmsReceivingAutomatic) |
|
312 { |
|
313 aRetrieval = MsgSettingEngine::AlwaysAutomatic; |
|
314 } |
|
315 |
|
316 aAnonymousStatus = mMmsSetting->AcceptAnonymousMessages(); |
|
317 |
|
318 aMmsAdvertsStatus = mMmsSetting->AcceptAdvertisementMessages(); |
|
319 |
|
320 CleanupStack::PopAndDestroy(2); |
|
321 } |
|
322 |
|
323 //--------------------------------------------------------------- |
|
324 // SmsSettings::iAPSelector |
|
325 // @see header |
|
326 //--------------------------------------------------------------- |
|
327 void MmsSettingsPrivate::getAllAccessPoints( |
|
328 RPointerArray<HBufC>& aAccessPoints, |
|
329 TInt& aDefaultIndex) |
|
330 { |
|
331 #ifdef _DEBUG_TRACES_ |
|
332 qDebug() << "Enter MmsSettingsPrivate::getAllAccessPoints: Index= " << aDefaultIndex; |
|
333 #endif |
|
334 |
|
335 CCommsDatabase *db; |
|
336 CCommsDbTableView *view; |
|
337 TInt result, err; |
|
338 |
|
339 //select the access point and store it in cenrep |
|
340 CMmsAccount* mmsAccount = CMmsAccount::NewL(); |
|
341 CleanupStack::PushL(mmsAccount); |
|
342 |
|
343 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
344 CleanupStack::PushL(mMmsSetting); |
|
345 |
|
346 mmsAccount->LoadSettingsL(*mMmsSetting); |
|
347 |
|
348 //select the default access point |
|
349 TInt32 defaultId = mMmsSetting->AccessPoint(0); |
|
350 |
|
351 TBuf<KCommsDbSvrMaxColumnNameLength> iapName; |
|
352 TBuf<KCommsDbSvrMaxFieldLength> serviceType; |
|
353 TUint32 iapId = 0; |
|
354 db = CCommsDatabase::NewL(EDatabaseTypeIAP); |
|
355 CleanupStack::PushL(db); |
|
356 view = db->OpenTableLC(TPtrC(IAP)); |
|
357 |
|
358 // Walk through records |
|
359 result = view->GotoFirstRecord(); |
|
360 TInt recordIndex = 0; |
|
361 while (result == KErrNone) |
|
362 { |
|
363 TRAP(err, view->ReadTextL(TPtrC(COMMDB_NAME), iapName)); |
|
364 TRAP(err, view->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType)); |
|
365 #ifdef __WINSCW__ |
|
366 if (serviceType.CompareF(TPtrC(LAN_SERVICE)) == 0) |
|
367 { |
|
368 HBufC* accessPointName = iapName.Alloc(); |
|
369 aAccessPoints.AppendL(accessPointName); |
|
370 TRAP(err, view->ReadUintL(TPtrC(COMMDB_ID), iapId)); |
|
371 |
|
372 // check to see if this is default set for MMsAccesspoint |
|
373 if (defaultId == iapId) |
|
374 { |
|
375 aDefaultIndex = recordIndex; |
|
376 } |
|
377 recordIndex++; |
|
378 } |
|
379 #else |
|
380 if(serviceType.CompareF(TPtrC(OUTGOING_GPRS)) == 0) |
|
381 { |
|
382 HBufC* accessPointName = iapName.Alloc(); |
|
383 aAccessPoints.AppendL(accessPointName); |
|
384 TRAP(err, view->ReadUintL(TPtrC(COMMDB_ID), iapId)); |
|
385 |
|
386 // check to see if this is default set for MMsAccesspoint |
|
387 if (defaultId == iapId) |
|
388 { |
|
389 aDefaultIndex = recordIndex; |
|
390 } |
|
391 recordIndex++; |
|
392 } |
|
393 #endif |
|
394 TRAP(err, result = view->GotoNextRecord()); |
|
395 } |
|
396 CleanupStack::PopAndDestroy(4); // nMmsSettings, db,view |
|
397 #ifdef _DEBUG_TRACES_ |
|
398 qDebug() << "Exit MmsSettingsPrivate::getAllAccessPoints: Index=" |
|
399 << aDefaultIndex |
|
400 << "\n"; |
|
401 #endif |
|
402 |
|
403 } |
|
404 |
|
405 //--------------------------------------------------------------- |
|
406 // MmsSettingsPrivate::setMMSAccesspoint |
|
407 // @see header |
|
408 //--------------------------------------------------------------- |
|
409 void MmsSettingsPrivate::setMMSAccesspoint(TInt& aDefaultIndex) |
|
410 { |
|
411 #ifdef _DEBUG_TRACES_ |
|
412 qDebug() << "Enter MmsSettingsPrivate::setMMSAccesspoint: Index=" |
|
413 << aDefaultIndex |
|
414 << "\n"; |
|
415 #endif |
|
416 |
|
417 |
|
418 //select the access point and store it in cenrep |
|
419 CMmsAccount* mmsAccount = CMmsAccount::NewL(); |
|
420 CleanupStack::PushL(mmsAccount); |
|
421 |
|
422 CMmsSettings* mMmsSetting = CMmsSettings::NewL(); |
|
423 CleanupStack::PushL(mMmsSetting); |
|
424 |
|
425 mmsAccount->LoadSettingsL(*mMmsSetting); |
|
426 |
|
427 CCommsDatabase *db; |
|
428 CCommsDbTableView *view; |
|
429 TInt result, err; |
|
430 |
|
431 TCommDbConnPref prefs; |
|
432 |
|
433 TBuf<KCommsDbSvrMaxColumnNameLength> iapName; |
|
434 TBuf<KCommsDbSvrMaxFieldLength> serviceType; |
|
435 TUint32 iapId = 0; |
|
436 db = CCommsDatabase::NewL(EDatabaseTypeIAP); |
|
437 CleanupStack::PushL(db); |
|
438 view = db->OpenTableLC(TPtrC(IAP)); |
|
439 |
|
440 // Walk through records |
|
441 result = view->GotoFirstRecord(); |
|
442 TInt serviceCounter = 0; |
|
443 while (result == KErrNone) |
|
444 { |
|
445 TRAP(err, view->ReadTextL(TPtrC(COMMDB_NAME), iapName)); |
|
446 TRAP(err, view->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType)); |
|
447 |
|
448 #ifdef __WINSCW__ |
|
449 if (serviceType.CompareF(TPtrC(LAN_SERVICE)) == 0 && serviceCounter |
|
450 == aDefaultIndex) |
|
451 { |
|
452 TRAP(err, view->ReadUintL(TPtrC(COMMDB_ID), iapId)); |
|
453 prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
454 prefs.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
455 prefs.SetIapId(iapId); |
|
456 |
|
457 while (mMmsSetting->AccessPointCount()) |
|
458 { |
|
459 mMmsSetting->DeleteAccessPointL(0); |
|
460 } |
|
461 if (iapId != 0) |
|
462 { |
|
463 #ifdef _DEBUG_TRACES_ |
|
464 qDebug() << "Set MMs Accesspoint IAP ID:" |
|
465 << iapId; |
|
466 #endif |
|
467 |
|
468 |
|
469 mMmsSetting->AddAccessPointL(iapId, 0); |
|
470 } |
|
471 mmsAccount->SaveSettingsL(*mMmsSetting); |
|
472 serviceCounter++; |
|
473 } |
|
474 else if (serviceType.CompareF(TPtrC(LAN_SERVICE)) == 0) |
|
475 { |
|
476 serviceCounter++; |
|
477 } |
|
478 #else |
|
479 if(serviceType.CompareF(TPtrC(OUTGOING_GPRS)) == 0 && |
|
480 serviceCounter == aDefaultIndex) |
|
481 { |
|
482 TRAP(err, view->ReadUintL(TPtrC(COMMDB_ID), iapId)); |
|
483 prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
484 prefs.SetDirection(ECommDbConnectionDirectionOutgoing); |
|
485 prefs.SetIapId(iapId); |
|
486 |
|
487 while ( mMmsSetting->AccessPointCount() ) |
|
488 { |
|
489 #ifdef _DEBUG_TRACES_ |
|
490 qDebug() << "Set MMs Accesspoint IAP ID:" |
|
491 << iapId; |
|
492 #endif |
|
493 |
|
494 mMmsSetting->DeleteAccessPointL( 0 ); |
|
495 } |
|
496 if ( iapId != 0 ) |
|
497 { |
|
498 mMmsSetting->AddAccessPointL(iapId, 0); |
|
499 } |
|
500 mmsAccount->SaveSettingsL(*mMmsSetting); |
|
501 serviceCounter++; |
|
502 } |
|
503 else if(serviceType.CompareF(TPtrC(OUTGOING_GPRS)) == 0) |
|
504 { |
|
505 serviceCounter++; |
|
506 } |
|
507 #endif |
|
508 TRAP(err, result = view->GotoNextRecord()); |
|
509 } |
|
510 |
|
511 CleanupStack::PopAndDestroy(4); // mMmsSetting, db,view |
|
512 #ifdef _DEBUG_TRACES_ |
|
513 qDebug() << "Exit MmsSettingsPrivate::setMMSAccesspoint: Index=" |
|
514 << aDefaultIndex |
|
515 << "\n"; |
|
516 #endif |
|
517 |
|
518 } |
|
519 |
|
520 //eof |
|
521 |
|