|
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 sms |
|
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 <csmsaccount.h> |
|
24 #include <smutset.h> |
|
25 #include "debugtraces.h" |
|
26 |
|
27 |
|
28 #include "smssettingsprivate.h" |
|
29 |
|
30 |
|
31 //two phase constructor |
|
32 SmsSettingsPrivate* SmsSettingsPrivate::NewL() |
|
33 { |
|
34 SmsSettingsPrivate* self = new (ELeave) SmsSettingsPrivate(); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 //2nd phase constructor |
|
42 void SmsSettingsPrivate::ConstructL() |
|
43 { |
|
44 //does nothing |
|
45 } |
|
46 |
|
47 //--------------------------------------------------------------- |
|
48 // SmsSettingsPrivate::SmsSettingsPrivate |
|
49 // @see header |
|
50 //--------------------------------------------------------------- |
|
51 SmsSettingsPrivate::SmsSettingsPrivate() |
|
52 { |
|
53 //do nothing |
|
54 } |
|
55 |
|
56 //--------------------------------------------------------------- |
|
57 // SmsSettingsPrivate::~SmsSettingsPrivate |
|
58 // @see header |
|
59 //--------------------------------------------------------------- |
|
60 SmsSettingsPrivate::~SmsSettingsPrivate() |
|
61 { |
|
62 //do nothing |
|
63 } |
|
64 |
|
65 void SmsSettingsPrivate::setCharacterEncodingL(TBool status) |
|
66 { |
|
67 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
68 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
69 |
|
70 smsAccount->LoadSettingsL(*smsSettings); |
|
71 |
|
72 if (status == EFalse) |
|
73 { |
|
74 smsSettings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
75 } |
|
76 else |
|
77 { |
|
78 smsSettings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2); |
|
79 } |
|
80 |
|
81 smsAccount->SaveSettingsL(*smsSettings); |
|
82 |
|
83 CleanupStack::PopAndDestroy(2); |
|
84 } |
|
85 |
|
86 void SmsSettingsPrivate::settingsCharEncodingL(TBool& statusEncoding) |
|
87 { |
|
88 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
89 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
90 |
|
91 smsAccount->LoadSettingsL(*smsSettings); |
|
92 |
|
93 TSmsDataCodingScheme::TSmsAlphabet charSet = smsSettings->CharacterSet(); |
|
94 |
|
95 statusEncoding = ETrue; |
|
96 if (charSet == TSmsDataCodingScheme::ESmsAlphabet7Bit) |
|
97 { |
|
98 statusEncoding = EFalse; |
|
99 } |
|
100 CleanupStack::PopAndDestroy(2); |
|
101 } |
|
102 |
|
103 void SmsSettingsPrivate::getAllSMSMessageCenterL( |
|
104 RPointerArray<HBufC>& accessPoints, |
|
105 TInt &defaultIndex) |
|
106 { |
|
107 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
108 CSmsSettings* settings = CSmsSettings::NewLC(); |
|
109 |
|
110 smsAccount->LoadSettingsL(*settings); |
|
111 |
|
112 //save the default index |
|
113 defaultIndex = settings->DefaultServiceCenter(); |
|
114 |
|
115 int totalSMSc = settings->ServiceCenterCount(); |
|
116 for (int index = 0; index < totalSMSc; index++) |
|
117 { |
|
118 TPtrC16 name = settings->GetServiceCenter(index).Name(); |
|
119 HBufC* accessName = name.AllocL(); |
|
120 accessPoints.AppendL(accessName); |
|
121 } |
|
122 |
|
123 CleanupStack::PopAndDestroy(2); |
|
124 |
|
125 return; |
|
126 } |
|
127 |
|
128 void SmsSettingsPrivate::setSMSMessageCenterL(int index) |
|
129 { |
|
130 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
131 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
132 |
|
133 smsAccount->LoadSettingsL(*smsSettings); |
|
134 smsSettings->SetDefaultServiceCenter(index); |
|
135 smsAccount->SaveSettingsL(*smsSettings); |
|
136 |
|
137 CleanupStack::PopAndDestroy(2); |
|
138 } |
|
139 |
|
140 void SmsSettingsPrivate::editSMSServiceCentreL(HBufC* address, HBufC* name, |
|
141 TInt index) |
|
142 { |
|
143 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
144 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
145 |
|
146 smsAccount->LoadSettingsL(*smsSettings); |
|
147 |
|
148 TInt indexDefault = smsSettings->DefaultServiceCenter(); |
|
149 bool flag = false; |
|
150 if (index == indexDefault) |
|
151 { |
|
152 flag = true; |
|
153 } |
|
154 |
|
155 //add a new service center |
|
156 smsSettings->AddServiceCenterL(name->Des(), address->Des()); |
|
157 |
|
158 if (flag == true) |
|
159 { |
|
160 smsSettings->SetDefaultServiceCenter( |
|
161 smsSettings->ServiceCenterCount()- 1); |
|
162 } |
|
163 |
|
164 //remove the service center |
|
165 smsSettings->RemoveServiceCenter(index); |
|
166 |
|
167 smsAccount->SaveSettingsL(*smsSettings); |
|
168 |
|
169 CleanupStack::PopAndDestroy(2); |
|
170 } |
|
171 |
|
172 void SmsSettingsPrivate::addSmsMessageCenterL(HBufC* address, HBufC* name) |
|
173 { |
|
174 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
175 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
176 |
|
177 smsAccount->LoadSettingsL(*smsSettings); |
|
178 |
|
179 int total_count = smsSettings->ServiceCenterCount(); |
|
180 smsSettings->AddServiceCenterL(name->Des(), address->Des()); |
|
181 |
|
182 if (total_count == 0) // no service center |
|
183 { |
|
184 smsSettings->SetDefaultServiceCenter(0); |
|
185 } |
|
186 smsSettings->SetCommDbAction(CSmsSettings::ENone); |
|
187 smsAccount->SaveSettingsL(*smsSettings); |
|
188 |
|
189 CleanupStack::PopAndDestroy(2); |
|
190 } |
|
191 |
|
192 void SmsSettingsPrivate::deleteSmsMessageCenterL(TInt aDeleteIndex) |
|
193 { |
|
194 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
195 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
196 |
|
197 smsAccount->LoadSettingsL(*smsSettings); |
|
198 |
|
199 TInt indexDefault = smsSettings->DefaultServiceCenter(); |
|
200 |
|
201 //remove from settings |
|
202 smsSettings->RemoveServiceCenter(aDeleteIndex); |
|
203 |
|
204 if (indexDefault == aDeleteIndex |
|
205 && smsSettings->ServiceCenterCount() > 0) |
|
206 { |
|
207 smsSettings->SetDefaultServiceCenter(0); |
|
208 } |
|
209 smsSettings->SetCommDbAction(CSmsSettings::ENone); |
|
210 smsAccount->SaveSettingsL(*smsSettings); |
|
211 |
|
212 CleanupStack::PopAndDestroy(2); |
|
213 } |
|
214 |
|
215 void SmsSettingsPrivate::smsCenterNameAndNumberL(int index, |
|
216 HBufC** centerNumber, |
|
217 HBufC** centerName) |
|
218 { |
|
219 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
220 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
221 |
|
222 smsAccount->LoadSettingsL(*smsSettings); |
|
223 |
|
224 TPtrC16 addr = smsSettings->GetServiceCenter(index).Address(); |
|
225 TPtrC16 name = smsSettings->GetServiceCenter(index).Name(); |
|
226 |
|
227 (*centerNumber) = addr.AllocL(); |
|
228 (*centerName) = name.AllocL(); |
|
229 |
|
230 CleanupStack::PopAndDestroy(2); |
|
231 } |
|
232 |
|
233 //eof |