author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 68 | 9da50d567e3c |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 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: Provides methods for fetching ringing tones into Phonebook. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <CPbk2RingingToneFetch.h> |
|
21 |
||
22 |
// Phonebook 2 |
|
68
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
23 |
#include <pbk2commonui.rsg> |
63 | 24 |
|
25 |
// System includes |
|
26 |
#include <cntfldst.h> |
|
27 |
#include <coemain.h> |
|
28 |
#include <mediafilelist.h> |
|
29 |
#include <centralrepository.h> |
|
30 |
#include <ProfileEngineDomainCRKeys.h> |
|
31 |
#include <DRMHelper.h> |
|
32 |
||
33 |
// ================= MEMBER FUNCTIONS ======================= |
|
34 |
inline CPbk2RingingToneFetch::CPbk2RingingToneFetch() |
|
35 |
{ |
|
36 |
} |
|
37 |
||
38 |
CPbk2RingingToneFetch::~CPbk2RingingToneFetch() |
|
39 |
{ |
|
40 |
delete iNoSound; |
|
41 |
delete iTitle; |
|
42 |
} |
|
43 |
||
44 |
EXPORT_C CPbk2RingingToneFetch* CPbk2RingingToneFetch::NewL() |
|
45 |
{ |
|
46 |
CPbk2RingingToneFetch* self = new ( ELeave ) CPbk2RingingToneFetch(); |
|
47 |
CleanupStack::PushL( self ); |
|
48 |
self->ConstructL(); |
|
49 |
CleanupStack::Pop( self ); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
inline void CPbk2RingingToneFetch::ConstructL() |
|
54 |
{ |
|
55 |
CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
56 |
iTitle = coeEnv->AllocReadResourceL( R_QTN_TC_POPUP_HEADING ); |
|
57 |
iNoSound = coeEnv->AllocReadResourceL( R_QTN_PHOP_SELI_DEFAULT_RTONE ); |
|
58 |
} |
|
59 |
||
60 |
EXPORT_C TBool CPbk2RingingToneFetch::FetchRingingToneL |
|
61 |
( TFileName& aRingingToneFile ) |
|
62 |
{ |
|
63 |
// Fetch the DefaultToneFile from Profile |
|
64 |
TFileName ringingToneFile; |
|
65 |
||
66 |
CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
67 |
CleanupStack::PushL( cenrep ); |
|
68 |
||
69 |
User::LeaveIfError( cenrep->Get( KProEngDefaultRingingTone, |
|
70 |
ringingToneFile ) ); |
|
71 |
CleanupStack::PopAndDestroy(); // cenrep |
|
72 |
||
73 |
CMediaFileList* list = CMediaFileList::NewL(); |
|
74 |
CleanupStack::PushL( list ); |
|
75 |
||
76 |
list->SetNullItemL( *iNoSound, ringingToneFile, |
|
77 |
CMediaFileList::EMediaFileTypeAudio, |
|
78 |
CMediaFileList::ENullItemIconDefaultTone ); |
|
79 |
list->SetAttrL( CMediaFileList::EAttrTitle, *iTitle ); |
|
80 |
SetMaxToneFileSizeL( list ); |
|
81 |
TInt nullItem = KErrNotFound; |
|
82 |
list->SetAttrL( CMediaFileList::EAttrAutomatedType, |
|
83 |
CDRMHelper::EAutomatedTypeRingingTone ); |
|
84 |
TBool result = list->ShowMediaFileListL( &aRingingToneFile, |
|
85 |
&nullItem, NULL, NULL ); |
|
86 |
CleanupStack::PopAndDestroy( list ); |
|
87 |
||
88 |
//if DefaultTone is selected, then empty aRingingToneFile |
|
89 |
if( !ringingToneFile.Compare(aRingingToneFile) ) |
|
90 |
{ |
|
91 |
aRingingToneFile.Zero(); |
|
92 |
} |
|
93 |
||
94 |
return result; |
|
95 |
} |
|
96 |
||
97 |
// -------------------------------------------------------------------------- |
|
98 |
// CPbk2RingingToneFetch::SetMaxToneFileSizeL |
|
99 |
// Limit the size of ringing tone files shown on the file list |
|
100 |
// according to cenrep key. |
|
101 |
// |
|
102 |
// @param aFL The ringing tone file list to limit |
|
103 |
// -------------------------------------------------------------------------- |
|
104 |
// |
|
105 |
void CPbk2RingingToneFetch::SetMaxToneFileSizeL( CMediaFileList* aFl ) |
|
106 |
{ |
|
107 |
// Set file size limit if configured ON. |
|
108 |
TInt sizeLimitKB( 0 ); |
|
109 |
CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
110 |
CleanupStack::PushL( cenrep ); |
|
111 |
||
112 |
User::LeaveIfError( cenrep->Get( KProEngRingingToneMaxSize, |
|
113 |
sizeLimitKB ) ); |
|
114 |
CleanupStack::PopAndDestroy(); // cenrep |
|
115 |
if ( sizeLimitKB < 0 ) |
|
116 |
{ |
|
117 |
sizeLimitKB = 0; |
|
118 |
} |
|
119 |
||
120 |
if ( sizeLimitKB ) |
|
121 |
{ |
|
122 |
aFl->SetAttrL( CMediaFileList::EAttrFileSize, sizeLimitKB ); |
|
123 |
} |
|
124 |
} |
|
125 |
||
126 |
// End of File |