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: Base class for file manager popups |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <StringLoader.h> |
|
22 #include <FileManagerView.rsg> |
|
23 #include <FileManagerDebug.h> |
|
24 #include <CFileManagerCommonDefinitions.h> |
|
25 #include "CFileManagerPopupBase.h" |
|
26 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
27 #include <aknmessagequerydialog.h> |
|
28 #else // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
29 #include <aknPopup.h> |
|
30 #include <aknlists.h> |
|
31 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
32 |
|
33 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
34 _LIT( KFmgrLineFeedWithClosingBoldTag, "</AknMessageQuery Bold>\n" ); |
|
35 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CFileManagerPopupBase::CFileManagerPopupBase |
|
41 // C++ default constructor can NOT contain any code, that |
|
42 // might leave. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CFileManagerPopupBase::CFileManagerPopupBase() |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CFileManagerPopupBase::ConstructL |
|
51 // Symbian 2nd phase constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CFileManagerPopupBase::ConstructL() |
|
55 { |
|
56 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
57 |
|
58 const TInt KLineFeedSpace = 2; |
|
59 const TInt KReservedForBoldTags = 600; |
|
60 TInt i( 0 ); |
|
61 TInt len( 0 ); |
|
62 MDesCArray* array = ConstructDataArrayL(); |
|
63 |
|
64 // Reformat array to a single buffer for CAknMessageQueryDialog. |
|
65 for ( i = 0; i < array->MdcaCount(); i++ ) |
|
66 { |
|
67 len += array->MdcaPoint( i ).Length() + KLineFeedSpace; |
|
68 len += KReservedForBoldTags; //Reserve some space for putting bold tags |
|
69 } |
|
70 iData = HBufC::New( len ); |
|
71 if ( !iData ) |
|
72 { |
|
73 delete array; |
|
74 User::LeaveNoMemory(); |
|
75 } |
|
76 TPtr ptr = iData->Des(); |
|
77 for ( i = 0; i < array->MdcaCount(); i++ ) |
|
78 { |
|
79 if ( i > 0 ) |
|
80 { |
|
81 ptr.Append( KFmgrLineFeed ); |
|
82 ptr.Append( KFmgrLineFeed ); |
|
83 } |
|
84 ptr.Append( KOpeningBoldTag ); // insert openning bold tag |
|
85 ptr.Append( array->MdcaPoint( i ) ); |
|
86 TInt tmpPos = ptr.Find( KFmgrTab ); |
|
87 ptr.Replace(tmpPos, 1, KFmgrLineFeedWithClosingBoldTag); |
|
88 } |
|
89 // AknTextUtils::ReplaceCharacters( ptr, KFmgrTab, KFmgrLineFeed()[0] ); |
|
90 delete array; |
|
91 |
|
92 #else // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
93 |
|
94 iListBox = new(ELeave) CAknDoublePopupMenuStyleListBox; |
|
95 iPopupList = CAknPopupList::NewL( iListBox, |
|
96 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
97 AknPopupLayouts::EMenuDoubleWindow ); |
|
98 iListBox->ConstructL( iPopupList, EAknListBoxViewerFlags ); |
|
99 |
|
100 MDesCArray* array = ConstructDataArrayL(); |
|
101 iListBox->Model()->SetItemTextArray( array ); |
|
102 |
|
103 iListBox->CreateScrollBarFrameL( ETrue ); |
|
104 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
105 CEikScrollBarFrame::EOff, |
|
106 CEikScrollBarFrame::EAuto ); |
|
107 iListBox->SetMopParent( this ); |
|
108 |
|
109 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CFileManagerPopupBase::~CFileManagerPopupBase |
|
114 // Destructor |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CFileManagerPopupBase::~CFileManagerPopupBase() |
|
118 { |
|
119 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
120 |
|
121 delete iTitle; |
|
122 delete iData; |
|
123 |
|
124 #else // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
125 |
|
126 if( iIsDestroyed ) |
|
127 { |
|
128 *iIsDestroyed = ETrue; |
|
129 } |
|
130 delete iListBox; |
|
131 |
|
132 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CFileManagerPopupBase::ExecuteLD |
|
137 // |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 TBool CFileManagerPopupBase::ExecuteLD() |
|
141 { |
|
142 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
143 |
|
144 CleanupStack::PushL( this ); |
|
145 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *iData ); |
|
146 dlg->PrepareLC( R_FILEMANAGER_POPUP_DIALOG ); |
|
147 dlg->QueryHeading()->SetTextL( *iTitle ); |
|
148 dlg->SetMopParent( this ); |
|
149 TCallBack cb( CFileManagerPopupBase::LinkCallback, this ); |
|
150 dlg->SetLink( cb ); |
|
151 TBool ret( dlg->RunLD() ); |
|
152 CleanupStack::PopAndDestroy( this ); |
|
153 return ret; |
|
154 |
|
155 #else // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
156 |
|
157 CFileManagerPopupBase* self = this; |
|
158 CleanupStack::PushL( self ); |
|
159 |
|
160 TBool thisDestroyed( EFalse ); |
|
161 iIsDestroyed = &thisDestroyed; |
|
162 |
|
163 TBool ret( EFalse ); |
|
164 TRAPD( err, ( ret = iPopupList->ExecuteLD() )); |
|
165 |
|
166 // just in case check is this base object still on, |
|
167 // before using member variable |
|
168 if( !thisDestroyed ) |
|
169 { |
|
170 iPopupList = NULL; |
|
171 } |
|
172 |
|
173 if( thisDestroyed ) |
|
174 { |
|
175 CleanupStack::Pop( self ); |
|
176 } |
|
177 else |
|
178 { |
|
179 CleanupStack::PopAndDestroy( self ); |
|
180 } |
|
181 |
|
182 User::LeaveIfError( err ); |
|
183 |
|
184 return ret; |
|
185 |
|
186 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CFileManagerPopupBase::SetTitleL |
|
191 // |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 void CFileManagerPopupBase::SetTitleL(const TDesC &aTitle) |
|
195 { |
|
196 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
197 |
|
198 if (iTitle) |
|
199 { |
|
200 delete iTitle; |
|
201 iTitle = NULL; |
|
202 } |
|
203 iTitle = aTitle.AllocL(); |
|
204 |
|
205 #else // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
206 |
|
207 iPopupList->SetTitleL( aTitle ); |
|
208 |
|
209 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
210 } |
|
211 |
|
212 #ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CFileManagerPopupBase::ActivateLinkL |
|
215 // |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 void CFileManagerPopupBase::ActivateLinkL() |
|
219 { |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CFileManagerPopupBase::LinkCallback |
|
224 // |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CFileManagerPopupBase::LinkCallback(TAny* aPtr) |
|
228 { |
|
229 CFileManagerPopupBase* ptr = static_cast<CFileManagerPopupBase*>( aPtr ); |
|
230 TRAPD( err, ptr->ActivateLinkL() ); |
|
231 ERROR_LOG1( "CFileManagerPopupBase::LinkCallback()-err:%d", err ) |
|
232 return err; |
|
233 } |
|
234 #endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM |
|
235 |
|
236 // End of File |
|