|
1 /* |
|
2 * Copyright (c) 2002-2006 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 * Provides methods for fetching ringing tones into phonebook. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkRingingToneFetch.h" |
|
22 #include <cntfldst.h> |
|
23 #include <coemain.h> |
|
24 #include <CFLDFileListContainer.h> |
|
25 #include <PbkView.rsg> |
|
26 #include <CPbkContactEngine.h> |
|
27 #include <CPbkFieldsInfo.h> |
|
28 #include <CPbkFieldInfo.h> |
|
29 #include <CPbkContactItem.h> |
|
30 #include <TPbkContactItemField.h> |
|
31 #include <CPbkConstants.h> |
|
32 #include <featmgr.h> |
|
33 #include <DRMHelper.h> |
|
34 #include <centralrepository.h> |
|
35 #include <ProfileEngineDomainCRKeys.h> |
|
36 |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 inline CPbkRingingToneFetch::CPbkRingingToneFetch |
|
40 (CPbkContactEngine& aEngine) : |
|
41 iEngine(aEngine) |
|
42 { |
|
43 } |
|
44 |
|
45 inline void CPbkRingingToneFetch::ConstructL() |
|
46 { |
|
47 FeatureManager::InitializeLibL(); |
|
48 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
49 iTitle = coeEnv->AllocReadResourceL(R_QTN_TC_POPUP_HEADING); |
|
50 iNoSound = coeEnv->AllocReadResourceL(R_QTN_PHOP_SELI_DEFAULT_RTONE); |
|
51 } |
|
52 |
|
53 EXPORT_C CPbkRingingToneFetch* CPbkRingingToneFetch::NewL(CPbkContactEngine& aEngine) |
|
54 { |
|
55 CPbkRingingToneFetch* self = new(ELeave) CPbkRingingToneFetch(aEngine); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(); // self |
|
59 return self; |
|
60 } |
|
61 |
|
62 CPbkRingingToneFetch::~CPbkRingingToneFetch() |
|
63 { |
|
64 // delete data members |
|
65 delete iNoSound; |
|
66 delete iTitle; |
|
67 FeatureManager::UnInitializeLib(); |
|
68 } |
|
69 |
|
70 EXPORT_C TBool CPbkRingingToneFetch::FetchRingingToneL |
|
71 (TFileName& aRingingToneFile) |
|
72 { |
|
73 CFLDFileListContainer* fileListDlg = CFLDFileListContainer::NewLC(); |
|
74 fileListDlg->InsertNullItemL(*iNoSound); |
|
75 SetMaxToneFileSizeL( fileListDlg ); |
|
76 fileListDlg->SetAutomatedType(CDRMHelper::EAutomatedTypeRingingTone); |
|
77 TBool result = fileListDlg->LaunchL(aRingingToneFile, *iTitle); |
|
78 CleanupStack::PopAndDestroy(fileListDlg); |
|
79 |
|
80 return result; |
|
81 } |
|
82 |
|
83 EXPORT_C void CPbkRingingToneFetch::SetRingingToneL |
|
84 (CPbkContactItem& aItem, |
|
85 TFileName& aRingingToneFile) |
|
86 { |
|
87 TPbkContactItemField* field = aItem.FindField(EPbkFieldIdPersonalRingingToneIndication); |
|
88 |
|
89 if (aRingingToneFile.Compare(KNullDesC) == 0) |
|
90 { |
|
91 // remove ringing tone field |
|
92 if (field) |
|
93 { |
|
94 const TDesC& oldRingingToneFile = field->Text(); |
|
95 HandleRingingToneRemovalL(oldRingingToneFile); |
|
96 aItem.RemoveField(aItem.FindFieldIndex(*field)); |
|
97 } |
|
98 } |
|
99 else |
|
100 { |
|
101 // ringing tone selected |
|
102 if (field) |
|
103 { |
|
104 // there was an old ringing tone stored => handle removal |
|
105 const TDesC& oldRingingToneFile = field->Text(); |
|
106 HandleRingingToneRemovalL(oldRingingToneFile); |
|
107 field->TextStorage()->SetTextL(aRingingToneFile); |
|
108 } |
|
109 else |
|
110 { |
|
111 // create ringing tone field |
|
112 CPbkFieldInfo* fieldInfo = iEngine.FieldsInfo().Find(EPbkFieldIdPersonalRingingToneIndication); |
|
113 TPbkContactItemField& newField = aItem.AddFieldL(*fieldInfo); |
|
114 newField.TextStorage()->SetTextL(aRingingToneFile); |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 void CPbkRingingToneFetch::HandleRingingToneRemovalL |
|
120 (const TDesC& aOldTone) |
|
121 { |
|
122 if (!FeatureManager::FeatureSupported(KFeatureIdDrmFull)) |
|
123 { |
|
124 return; |
|
125 } |
|
126 |
|
127 if (aOldTone.Compare(KNullDesC) != 0) |
|
128 { |
|
129 CDRMHelper* drmHelper = CDRMHelper::NewL(); |
|
130 drmHelper->RemoveAutomatedPassive(aOldTone); |
|
131 delete drmHelper; |
|
132 } |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CPbkRingingToneFetch::SetMaxToneFileSizeL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CPbkRingingToneFetch::SetMaxToneFileSizeL( CFLDFileListContainer* aFl ) |
|
140 { |
|
141 // Set file size limit if configured ON. |
|
142 TInt sizeLimitB( 0 ); |
|
143 CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine ); |
|
144 CleanupStack::PushL( cenrep ); |
|
145 |
|
146 User::LeaveIfError( cenrep->Get( KProEngRingingToneMaxSize, |
|
147 sizeLimitB ) ); |
|
148 CleanupStack::PopAndDestroy(); // cenrep |
|
149 if ( sizeLimitB < 0 ) |
|
150 { |
|
151 sizeLimitB = 0; |
|
152 } |
|
153 sizeLimitB *= 1024; |
|
154 if ( sizeLimitB ) |
|
155 { |
|
156 aFl->SetMaxFileSize( sizeLimitB ); |
|
157 } |
|
158 } |
|
159 |
|
160 // End of File |