|
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::setReceiveSerivceMessages( |
|
66 TBool serviceMessages) |
|
67 { |
|
68 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
69 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
70 |
|
71 smsAccount->LoadSettingsL(*smsSettings); |
|
72 |
|
73 //TODO set the receive message part |
|
74 |
|
75 smsAccount->SaveSettingsL(*smsSettings); |
|
76 |
|
77 CleanupStack::PopAndDestroy(2); |
|
78 } |
|
79 |
|
80 void SmsSettingsPrivate::setCharacterEncoding(TBool status) |
|
81 { |
|
82 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
83 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
84 |
|
85 smsAccount->LoadSettingsL(*smsSettings); |
|
86 |
|
87 if (status == EFalse) |
|
88 { |
|
89 smsSettings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
90 } |
|
91 else |
|
92 { |
|
93 smsSettings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2); |
|
94 } |
|
95 |
|
96 smsAccount->SaveSettingsL(*smsSettings); |
|
97 |
|
98 CleanupStack::PopAndDestroy(2); |
|
99 } |
|
100 |
|
101 void SmsSettingsPrivate::settingsServiceMessagesAndCharEncoding( |
|
102 TBool& report, |
|
103 TBool& statusEncoding) |
|
104 { |
|
105 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
106 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
107 |
|
108 smsAccount->LoadSettingsL(*smsSettings); |
|
109 |
|
110 //TODO: service messages read |
|
111 |
|
112 TSmsDataCodingScheme::TSmsAlphabet charSet = smsSettings->CharacterSet(); |
|
113 |
|
114 statusEncoding = ETrue; |
|
115 if (charSet == TSmsDataCodingScheme::ESmsAlphabet7Bit) |
|
116 { |
|
117 statusEncoding = EFalse; |
|
118 } |
|
119 CleanupStack::PopAndDestroy(2); |
|
120 } |
|
121 |
|
122 void SmsSettingsPrivate::getAllSMSMessageCenter( |
|
123 RPointerArray<HBufC>& accessPoints, |
|
124 TInt &defaultIndex) |
|
125 { |
|
126 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
127 CSmsSettings* settings = CSmsSettings::NewLC(); |
|
128 |
|
129 smsAccount->LoadSettingsL(*settings); |
|
130 |
|
131 //save the default index |
|
132 defaultIndex = settings->DefaultServiceCenter(); |
|
133 |
|
134 int totalSMSc = settings->ServiceCenterCount(); |
|
135 for (int index = 0; index < totalSMSc; index++) |
|
136 { |
|
137 TPtrC16 name = settings->GetServiceCenter(index).Name(); |
|
138 HBufC* accessName = name.AllocL(); |
|
139 accessPoints.AppendL(accessName); |
|
140 } |
|
141 |
|
142 CleanupStack::PopAndDestroy(2); |
|
143 |
|
144 return; |
|
145 } |
|
146 |
|
147 void SmsSettingsPrivate::setSMSMessageCenter(int index) |
|
148 { |
|
149 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
150 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
151 |
|
152 smsAccount->LoadSettingsL(*smsSettings); |
|
153 smsSettings->SetDefaultServiceCenter(index); |
|
154 smsAccount->SaveSettingsL(*smsSettings); |
|
155 |
|
156 CleanupStack::PopAndDestroy(2); |
|
157 } |
|
158 |
|
159 void SmsSettingsPrivate::editSMSServiceCentre(HBufC* address, HBufC* name, |
|
160 TInt index) |
|
161 { |
|
162 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
163 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
164 |
|
165 smsAccount->LoadSettingsL(*smsSettings); |
|
166 |
|
167 TInt indexDefault = smsSettings->DefaultServiceCenter(); |
|
168 bool flag = false; |
|
169 if (index == indexDefault) |
|
170 { |
|
171 flag = true; |
|
172 } |
|
173 |
|
174 //remove the service center |
|
175 //smsSettings->RemoveServiceCenter(index); |
|
176 //add a new service center |
|
177 smsSettings->AddServiceCenterL(name->Des(), address->Des()); |
|
178 |
|
179 if (flag == true) |
|
180 { |
|
181 smsSettings->SetDefaultServiceCenter( |
|
182 smsSettings->ServiceCenterCount()- 1); |
|
183 } |
|
184 |
|
185 smsAccount->SaveSettingsL(*smsSettings); |
|
186 |
|
187 smsAccount->LoadSettingsL(*smsSettings); |
|
188 if (flag == true) |
|
189 { |
|
190 smsSettings->RemoveServiceCenter(index); |
|
191 } |
|
192 |
|
193 smsAccount->SaveSettingsL(*smsSettings); |
|
194 |
|
195 CleanupStack::PopAndDestroy(2); |
|
196 } |
|
197 |
|
198 void SmsSettingsPrivate::addSmsMessageCenter(HBufC* address, HBufC* name) |
|
199 { |
|
200 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
201 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
202 |
|
203 smsAccount->LoadSettingsL(*smsSettings); |
|
204 |
|
205 int total_count = smsSettings->ServiceCenterCount(); |
|
206 smsSettings->AddServiceCenterL(name->Des(), address->Des()); |
|
207 |
|
208 if (total_count == 0) // no service center |
|
209 { |
|
210 smsSettings->SetDefaultServiceCenter(0); |
|
211 } |
|
212 smsSettings->SetCommDbAction(CSmsSettings::ENone); |
|
213 smsAccount->SaveSettingsL(*smsSettings); |
|
214 |
|
215 CleanupStack::PopAndDestroy(2); |
|
216 } |
|
217 |
|
218 void SmsSettingsPrivate::deleteSmsMessageCenter(TInt aDeleteIndex) |
|
219 { |
|
220 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
221 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
222 |
|
223 smsAccount->LoadSettingsL(*smsSettings); |
|
224 |
|
225 TInt indexDefault = smsSettings->DefaultServiceCenter(); |
|
226 |
|
227 //remove from settings |
|
228 smsSettings->RemoveServiceCenter(aDeleteIndex); |
|
229 |
|
230 if (indexDefault == aDeleteIndex |
|
231 && smsSettings->ServiceCenterCount() > 0) |
|
232 { |
|
233 smsSettings->SetDefaultServiceCenter(0); |
|
234 } |
|
235 smsSettings->SetCommDbAction(CSmsSettings::ENone); |
|
236 smsAccount->SaveSettingsL(*smsSettings); |
|
237 |
|
238 CleanupStack::PopAndDestroy(2); |
|
239 } |
|
240 |
|
241 void SmsSettingsPrivate::smsCenterNameAndNumber(int index, |
|
242 HBufC** centerNumber, |
|
243 HBufC** centerName) |
|
244 { |
|
245 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
246 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
247 |
|
248 smsAccount->LoadSettingsL(*smsSettings); |
|
249 |
|
250 TPtrC16 addr = smsSettings->GetServiceCenter(index).Address(); |
|
251 TPtrC16 name = smsSettings->GetServiceCenter(index).Name(); |
|
252 |
|
253 (*centerNumber) = addr.AllocL(); |
|
254 (*centerName) = name.AllocL(); |
|
255 |
|
256 CleanupStack::PopAndDestroy(2); |
|
257 } |
|
258 |
|
259 //eof |