author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:32:06 +0100 | |
branch | GCC_SURGE |
changeset 47 | 5b14749788d7 |
parent 27 | e4592d119491 |
parent 43 | 35b64624a9e7 |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2010 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 |
* A class which takes care of reading the possible new |
|
16 |
* service centres from SIM and adds them to pda-side Sms Settings. |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
// SYSTEM INCLUDES |
|
21 |
#include <pathinfo.h> |
|
22 |
#include <f32file.h> |
|
23 |
#include <hbmessagebox.h> |
|
24 |
||
25 |
// USER INCLUDES |
|
26 |
#include "ringbc_p.h" |
|
27 |
#include "ringbctoneconverter.h" |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
28 |
#include <xqconversions.h> |
31 | 29 |
#include "debugtraces.h" |
30 |
||
31 |
//CONSTANTS |
|
32 |
_LIT(KRingingToneFileExtension,".rng"); |
|
33 |
||
34 |
||
35 |
// ---------------------------------------------------------------------------- |
|
36 |
// RingBcPrivate::RingBcPrivate |
|
37 |
// @see ringbc_p.h |
|
38 |
// ---------------------------------------------------------------------------- |
|
39 |
RingBcPrivate::RingBcPrivate() |
|
40 |
||
41 |
{ |
|
42 |
QDEBUG_WRITE("RingBcPrivate::RingBcPrivate : Enter") |
|
43 |
||
44 |
TRAP_IGNORE(initL()); |
|
45 |
||
46 |
QDEBUG_WRITE("RingBcPrivate::RingBcPrivate : Exit") |
|
47 |
||
48 |
} |
|
49 |
||
50 |
// ---------------------------------------------------------------------------- |
|
51 |
// RingBcPrivate::~RingBcPrivate |
|
52 |
// @see ringbc_p.h |
|
53 |
// ---------------------------------------------------------------------------- |
|
54 |
RingBcPrivate::~RingBcPrivate() |
|
55 |
{ |
|
56 |
QDEBUG_WRITE("RingBcPrivate::~RingBcPrivate : Enter") |
|
57 |
||
58 |
delete mConverter; |
|
59 |
||
60 |
QDEBUG_WRITE("RingBcPrivate::~RingBcPrivate : Exit") |
|
61 |
} |
|
62 |
||
63 |
// ---------------------------------------------------------------------------- |
|
64 |
// RingBcPrivate::initL |
|
65 |
// @see ringbc_p.h |
|
66 |
// ---------------------------------------------------------------------------- |
|
67 |
void RingBcPrivate::initL() |
|
68 |
{ |
|
69 |
QDEBUG_WRITE("RingBcPrivate::initL : Enter") |
|
70 |
||
71 |
mConverter = RingBCNSMConverter::NewL(); |
|
72 |
||
73 |
QDEBUG_WRITE("RingBcPrivate::initL : Exit") |
|
74 |
} |
|
75 |
||
76 |
// ---------------------------------------------------------------------------- |
|
77 |
// RingBcPrivate::saveTone |
|
78 |
// @see ringbc_p.h |
|
79 |
// ---------------------------------------------------------------------------- |
|
80 |
void RingBcPrivate::saveTone(const QString &path) |
|
81 |
{ |
|
82 |
QDEBUG_WRITE("RingBcPrivate::saveTone : Enter") |
|
83 |
||
84 |
int error(KErrNone); |
|
85 |
||
86 |
TRAP(error, saveToneL(path)); |
|
87 |
if (error) |
|
88 |
{ |
|
89 |
QDEBUG_WRITE_FORMAT("RingBcPrivate::saveTone Error code =",error) |
|
90 |
||
91 |
if(error == KErrCorrupt) |
|
92 |
{ |
|
93 |
HbMessageBox::information("Ringing Tone Corrupted"); |
|
94 |
QDEBUG_WRITE("RingBcPrivate::saveTone : Ringing tone corrupted") |
|
95 |
} |
|
96 |
else if(error == KErrNoMemory || error == KErrDiskFull) |
|
97 |
{ |
|
98 |
HbMessageBox::information("No memory to save"); |
|
99 |
QDEBUG_WRITE("RingBcPrivate::saveTone : Low memory") |
|
100 |
} |
|
101 |
else |
|
102 |
{ |
|
103 |
HbMessageBox::information("Error in Saving"); |
|
104 |
QDEBUG_WRITE("RingBcPrivate::saveTone : Error in Saving") |
|
105 |
} |
|
106 |
} |
|
107 |
else |
|
108 |
{ |
|
109 |
HbMessageBox::information("Saved succesfully"); |
|
110 |
QDEBUG_WRITE("RingBcPrivate::saveTone : Ringing tone saved successfully") |
|
111 |
} |
|
112 |
||
113 |
QDEBUG_WRITE("RingBcPrivate::saveTone : Exit") |
|
114 |
} |
|
115 |
||
116 |
// ---------------------------------------------------------------------------- |
|
117 |
// RingBcPrivate::saveToneL |
|
118 |
// @see ringbc_p.h |
|
119 |
// ---------------------------------------------------------------------------- |
|
120 |
void RingBcPrivate::saveToneL(const QString& path) |
|
121 |
{ |
|
122 |
QDEBUG_WRITE("RingBcPrivate::saveToneL : Enter") |
|
123 |
||
124 |
QStringList pathList = path.split("."); |
|
125 |
QString extension = QString(".") + pathList.at(pathList.count() - 1); |
|
126 |
||
127 |
RFs fsSession; |
|
128 |
User::LeaveIfError(fsSession.Connect()); |
|
129 |
||
130 |
CleanupClosePushL(fsSession); |
|
131 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
132 |
HBufC* fileName = XQConversions::qStringToS60Desc(path); |
31 | 133 |
|
134 |
RFile file; |
|
135 |
User::LeaveIfError(file.Open(fsSession, fileName->Des(), |
|
136 |
EFileShareReadersOnly)); |
|
137 |
||
138 |
CleanupClosePushL(file); |
|
139 |
TInt size; |
|
140 |
User::LeaveIfError(file.Size(size)); |
|
141 |
||
142 |
HBufC8* dataBuf = HBufC8::NewLC(size); |
|
143 |
TPtr8 data(dataBuf->Des()); |
|
144 |
User::LeaveIfError(file.Read(data, size)); |
|
145 |
||
146 |
TBool valid = mConverter->IsRingToneMimeTypeL(data); |
|
147 |
||
148 |
if (valid) |
|
149 |
{ |
|
150 |
HBufC* title = mConverter->TitleLC(data); |
|
151 |
TFileName path = PathInfo::PhoneMemoryRootPath(); |
|
152 |
path.Append(PathInfo::SimpleSoundsPath()); |
|
153 |
path.Append(*title); |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
154 |
HBufC* fileExtension = XQConversions::qStringToS60Desc(extension); |
31 | 155 |
path.Append(fileExtension->Des()); |
156 |
||
157 |
CFileMan* fileMan = CFileMan::NewL(fsSession); |
|
158 |
CleanupStack::PushL(fileMan); |
|
159 |
if(fileMan) |
|
160 |
{ |
|
161 |
TInt err = fileMan->Copy(fileName->Des(), path, CFileMan::ECopy | CFileMan::EOverWrite); |
|
162 |
User::LeaveIfError(err); |
|
163 |
} |
|
164 |
CleanupStack::PopAndDestroy(2); // title,fileMan |
|
165 |
} |
|
166 |
||
167 |
CleanupStack::PopAndDestroy(); // dataBuf |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
168 |
CleanupStack::PopAndDestroy(); //file |
31 | 169 |
CleanupStack::PopAndDestroy(); //fsSession |
170 |
||
171 |
QDEBUG_WRITE("RingBcPrivate::saveToneL : Exit") |
|
172 |
} |
|
173 |
||
174 |
// ---------------------------------------------------------------------------- |
|
175 |
// RingBcPrivate::toneTitle |
|
176 |
// @see ringbc_p.h |
|
177 |
// ---------------------------------------------------------------------------- |
|
178 |
QString RingBcPrivate::toneTitle(const QString &path) |
|
179 |
{ |
|
180 |
QDEBUG_WRITE("RingBcPrivate::toneTitle : Enter") |
|
181 |
||
182 |
QString title; |
|
183 |
QStringList pathList = path.split("."); |
|
184 |
QString extension = pathList.at(pathList.count() - 1); |
|
185 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
186 |
HBufC* fileName = XQConversions::qStringToS60Desc(path); |
31 | 187 |
TRAP_IGNORE( title = titleL(*fileName)); |
188 |
||
189 |
title.append(QChar('.')); |
|
190 |
title.append(extension); |
|
191 |
||
192 |
QDEBUG_WRITE("RingBcPrivate::toneTitle : Exit") |
|
193 |
return title; |
|
194 |
} |
|
195 |
||
196 |
// ---------------------------------------------------------------------------- |
|
197 |
// RingBcPrivate::titleL |
|
198 |
// @see ringbc_p.h |
|
199 |
// ---------------------------------------------------------------------------- |
|
200 |
QString RingBcPrivate::titleL(const TDesC& aFileName) |
|
201 |
{ |
|
202 |
QDEBUG_WRITE("RingBcPrivate::titleL : Enter") |
|
203 |
||
204 |
QString title; // initialize to null string |
|
205 |
RFs fsSession; |
|
206 |
TInt error = fsSession.Connect(); |
|
207 |
if (error == KErrNone) |
|
208 |
{ |
|
209 |
CleanupClosePushL(fsSession); |
|
210 |
||
211 |
RFile file; |
|
212 |
error = file.Open(fsSession, aFileName, EFileRead); |
|
213 |
||
214 |
if (error == KErrNone) |
|
215 |
{ |
|
216 |
CleanupClosePushL(file); |
|
217 |
TInt size; |
|
218 |
User::LeaveIfError(file.Size(size)); |
|
219 |
if (size) |
|
220 |
{ |
|
221 |
HBufC8* dataBuf = HBufC8::NewLC(size); |
|
222 |
TPtr8 data(dataBuf->Des()); |
|
223 |
User::LeaveIfError(file.Read(data, size)); |
|
224 |
||
225 |
TBool valid = mConverter->IsRingToneMimeTypeL(data); |
|
226 |
if (valid) |
|
227 |
{ |
|
228 |
HBufC* toneTitle = mConverter->TitleLC(data); |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
229 |
title = XQConversions::s60DescToQString(*toneTitle); |
31 | 230 |
CleanupStack::PopAndDestroy(); //title |
231 |
} |
|
232 |
CleanupStack::PopAndDestroy(); //dataBuf |
|
233 |
} |
|
234 |
CleanupStack::PopAndDestroy(); //file |
|
235 |
} |
|
236 |
CleanupStack::PopAndDestroy(); //fsSession |
|
237 |
} |
|
238 |
QDEBUG_WRITE("RingBcPrivate::titleL : Exit") |
|
239 |
return title; |
|
240 |
} |
|
241 |
||
242 |
// End of File |