|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <smutset.h> |
|
20 #include <csmsaccount.h> |
|
21 |
|
22 #include "logger.h" |
|
23 #include "cservicecentrenumretrievers60impl.h" |
|
24 #include "smsservicecentrenumretriever.h" |
|
25 |
|
26 namespace java |
|
27 { |
|
28 namespace wma |
|
29 { |
|
30 |
|
31 /** |
|
32 * This function retrieves service centre number. Returns null if not able to |
|
33 * retrieve service centre number |
|
34 */ |
|
35 jstring SmsServiceCentreNumRetriever::getServiceCentreNum(JNIEnv& aJni) |
|
36 { |
|
37 JELOG2(EWMA); |
|
38 TBuf<RMobilePhone::KMaxMobileTelNumberSize> scNumber; |
|
39 TRAPD(error, |
|
40 CServiceCentreNumRetrieverS60Impl::retrieveServiceCentreNumberL(scNumber)); |
|
41 if (error != KErrNone) |
|
42 { |
|
43 ELOG1(EWMA, "SMS : error while retrieving SMSC number : %d", error); |
|
44 return NULL; |
|
45 } |
|
46 return aJni.NewString((jchar*) scNumber.Ptr(), scNumber.Length()); |
|
47 } |
|
48 |
|
49 /* Fetches the service centre phone number from the Messaging settings. |
|
50 * If there is no service center set in Message settings, it leaves. |
|
51 */ |
|
52 void CServiceCentreNumRetrieverS60Impl::retrieveServiceCentreNumberL( |
|
53 TDes& smscNum) |
|
54 { |
|
55 JELOG2(EWMA); |
|
56 CSmsAccount* messageAccount = CSmsAccount::NewLC(); |
|
57 CSmsSettings* messageSettings = CSmsSettings::NewLC(); |
|
58 messageAccount->LoadSettingsL(*messageSettings); |
|
59 TInt scIndex = messageSettings->DefaultServiceCenter(); |
|
60 if (scIndex < KErrNone) |
|
61 { |
|
62 ELOG(EWMA,"SMS ERROR: SMSC is not defined in SMS Settings"); |
|
63 User::LeaveIfError(scIndex); |
|
64 } |
|
65 LOG(EWMA, EInfo, "SMS :: Defined SMSC in SmsSettings"); |
|
66 // get the service center currently in use from |
|
67 // message settings |
|
68 CSmsServiceCenter& sc = messageSettings->GetServiceCenter(scIndex); |
|
69 smscNum.Append(sc.Address()); |
|
70 CleanupStack::PopAndDestroy(messageSettings); |
|
71 CleanupStack::PopAndDestroy(messageAccount); |
|
72 } |
|
73 |
|
74 } //namespace wma |
|
75 } //namespace java |