author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:32:09 +0300 | |
branch | RCL_3 |
changeset 75 | 01504893d9cb |
parent 64 | 34937ec34dac |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2008-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 |
* |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
14 |
* Description: Delete command handler |
60 | 15 |
* |
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
21 |
/** |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
22 |
* @internal reviewed 06/06/2007 by Dave Schofield |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
23 |
*/ |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
24 |
|
60 | 25 |
#include "glxcommandhandlernewmedia.h" |
26 |
||
27 |
#include <AknUtils.h> |
|
28 |
#include <badesca.h> |
|
29 |
#include <bautils.h> |
|
30 |
#include <glxattributecontext.h> |
|
31 |
#include <glxattributeretriever.h> |
|
32 |
#include <glxcollectiongeneraldefs.h> |
|
33 |
#include <glxcommandfactory.h> |
|
34 |
#include <glxcommandhandlers.hrh> |
|
35 |
#include <glxfetchcontextremover.h> |
|
36 |
#include <glxgeneraluiutilities.h> |
|
37 |
#include <glxpanic.h> |
|
38 |
#include <glxtracer.h> |
|
39 |
#include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
40 |
#include <glxsetappstate.h> |
|
41 |
#include <glxtextentrypopup.h> |
|
42 |
#include <glxuistd.h> |
|
43 |
#include <glxuiutilities.rsg> |
|
44 |
#include <mglxmedialist.h> |
|
45 |
#include <mpxcollectionpath.h> |
|
46 |
#include <mpxcommonframeworkdefs.h> |
|
47 |
#include <StringLoader.h> |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
48 |
|
60 | 49 |
#include <data_caging_path_literals.hrh> |
50 |
#include <glxuiutilities.rsg> |
|
51 |
||
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
52 |
const TInt KMaxMediaPopupTitleLength = 0x28; // Accepts only 40 characters |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
53 |
const TInt KMaxNewMediaItemTitleLength = 0x28; // Accepts only 40 characters |
60 | 54 |
const TInt KMaxNumberLength = 10; |
55 |
||
56 |
_LIT(KOpenBracket, "("); |
|
57 |
_LIT(KCloseBracket, ")"); |
|
58 |
_LIT(KFileNameFormatString, "(%+02u)"); |
|
59 |
||
60 |
// --------------------------------------------------------------------------- |
|
61 |
// Two-phased constructor. |
|
62 |
// --------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
EXPORT_C CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL( |
|
65 |
MGlxMediaListProvider* aMediaListProvider, const TDesC& aFileName) |
|
66 |
{ |
|
67 |
TRACER("CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL"); |
|
68 |
CGlxCommandHandlerNewMedia* self = new (ELeave) CGlxCommandHandlerNewMedia( |
|
69 |
aMediaListProvider); |
|
70 |
CleanupStack::PushL(self); |
|
71 |
self->ConstructL(aFileName); |
|
72 |
CleanupStack::Pop(self); |
|
73 |
return self; |
|
74 |
} |
|
75 |
||
76 |
// --------------------------------------------------------------------------- |
|
77 |
// C++ default constructor can NOT contain any code, that |
|
78 |
// might leave. |
|
79 |
// --------------------------------------------------------------------------- |
|
80 |
// |
|
81 |
CGlxCommandHandlerNewMedia::CGlxCommandHandlerNewMedia(MGlxMediaListProvider* aMediaListProvider) |
|
82 |
: CGlxMpxCommandCommandHandler(aMediaListProvider) |
|
83 |
{ |
|
84 |
// Don't do anything. |
|
85 |
} |
|
86 |
||
87 |
// ----------------------------------------------------------------------------- |
|
88 |
// CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL |
|
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
void CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL(TAny* /*aSessionId*/, CMPXCommand* aCommandResult, |
|
92 |
TInt aError, MGlxMediaList* /*aList*/) |
|
93 |
{ |
|
94 |
TRACER("CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL"); |
|
95 |
if (aError == KErrNone && aCommandResult && aCommandResult->IsSupported(KMPXMediaGeneralId)) |
|
96 |
{ |
|
97 |
iNewMediaId = TGlxMediaId(aCommandResult->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
98 |
iOkToExit = EFalse; // wait for media id to be added to the list |
|
99 |
// (unless we are using iSchedulerWait) |
|
100 |
} |
|
101 |
||
102 |
if (iSchedulerWait && aError != KErrAlreadyExists ) |
|
103 |
{ |
|
104 |
// if iSchedulerWait exists then we know the command is being executed from |
|
105 |
// the ExecuteLD() method. |
|
106 |
iNewMediaCreationError = aError; |
|
107 |
iSchedulerWait->AsyncStop(); |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
// ----------------------------------------------------------------------------- |
|
112 |
// CGlxCommandHandlerNewMedia::OkToExit |
|
113 |
// ----------------------------------------------------------------------------- |
|
114 |
// |
|
115 |
EXPORT_C TBool CGlxCommandHandlerNewMedia::OkToExit() const |
|
116 |
{ |
|
117 |
return iOkToExit; |
|
118 |
} |
|
119 |
||
120 |
// --------------------------------------------------------------------------- |
|
121 |
// Symbian 2nd phase constructor can leave. |
|
122 |
// --------------------------------------------------------------------------- |
|
123 |
// |
|
124 |
void CGlxCommandHandlerNewMedia::ConstructL(const TDesC& aFileName) |
|
125 |
{ |
|
126 |
TRACER("CGlxCommandHandlerNewMedia::ConstructL()"); |
|
127 |
iFileNameAlreadyExists = EFalse; |
|
128 |
||
129 |
iResourceOffset = CCoeEnv::Static()->AddResourceFileL(aFileName); |
|
130 |
||
131 |
iAsyncFocuser = new (ELeave) CGlxAsyncFocuser(this); |
|
132 |
// Add supported command |
|
133 |
TCommandInfo info(EGlxCmdAddMedia); |
|
134 |
// Filter out static items |
|
135 |
AddCommandL(info); |
|
136 |
} |
|
137 |
||
138 |
// --------------------------------------------------------------------------- |
|
139 |
// Destructor |
|
140 |
// --------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
EXPORT_C CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia() |
|
143 |
{ |
|
144 |
TRACER("CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia()"); |
|
145 |
if ( iResourceOffset ) |
|
146 |
{ |
|
147 |
CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
148 |
} |
|
149 |
||
150 |
delete iSchedulerWait; |
|
151 |
delete iAsyncFocuser; |
|
152 |
delete iNewMediaItemTitle; |
|
153 |
} |
|
154 |
||
155 |
// --------------------------------------------------------------------------- |
|
156 |
// CGlxCommandHandlerNewMedia::ExecuteLD() |
|
157 |
// --------------------------------------------------------------------------- |
|
158 |
// |
|
159 |
EXPORT_C TInt CGlxCommandHandlerNewMedia::ExecuteLD(TGlxMediaId& aNewMediaId) |
|
160 |
{ |
|
161 |
TRACER("CGlxCommandHandlerNewMedia::ExecuteLD"); |
|
162 |
CleanupStack::PushL(this); |
|
163 |
iSchedulerWait = new (ELeave) CActiveSchedulerWait(); |
|
164 |
||
165 |
CGlxMpxCommandCommandHandler::ExecuteL( EGlxCmdAddMedia ); |
|
166 |
if (iNewMediaCreationError == KErrNone) |
|
167 |
{ |
|
168 |
// The user pressed OK on the dialog. We need to wait for DoHandleCommandComplete() |
|
169 |
iSchedulerWait->Start(); |
|
170 |
||
171 |
if (iNewMediaCreationError == KErrNone) |
|
172 |
{ |
|
173 |
aNewMediaId = iNewMediaId; |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
TInt error = iNewMediaCreationError; |
|
178 |
CleanupStack::PopAndDestroy(this); |
|
179 |
return error; |
|
180 |
} |
|
181 |
||
182 |
// --------------------------------------------------------------------------- |
|
183 |
// Create an add to container command |
|
184 |
// --------------------------------------------------------------------------- |
|
185 |
// |
|
186 |
CMPXCommand* CGlxCommandHandlerNewMedia::CreateCommandL(TInt /*aCommandId*/, |
|
187 |
MGlxMediaList& aMediaList, TBool& /*aConsume*/) const |
|
188 |
{ |
|
189 |
TRACER("CGlxCommandHandlerNewMedia::CreateCommandL"); |
|
190 |
iOkToExit = ETrue; |
|
191 |
||
192 |
CMPXCollectionPath* path = aMediaList.PathLC( NGlxListDefs::EPathParent ); |
|
193 |
CMPXCommand* command = NULL; |
|
194 |
||
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
195 |
TBuf <KMaxNewMediaItemTitleLength> defaultNewMediaItemTitle; |
60 | 196 |
|
197 |
TRAPD(error, TitlesL(TGlxMediaId(path->Id(0)), defaultNewMediaItemTitle)); |
|
198 |
if(error != KErrNone) |
|
199 |
{ |
|
200 |
iNewMediaCreationError = KErrCancel; |
|
201 |
CleanupStack::PopAndDestroy(path); |
|
202 |
return command; |
|
203 |
} |
|
204 |
||
205 |
HBufC* mediaPopupTitle = StringLoader::LoadLC(R_GLX_PROMPT_NAME); |
|
206 |
if(iFileNameAlreadyExists) |
|
207 |
{ |
|
208 |
iFileNameAlreadyExists = EFalse ; |
|
209 |
} |
|
210 |
else |
|
211 |
{ |
|
212 |
delete iNewMediaItemTitle; |
|
213 |
iNewMediaItemTitle = NULL; |
|
214 |
iNewMediaItemTitle = GenerateNewMediaItemTitleL(defaultNewMediaItemTitle, aMediaList); |
|
215 |
} |
|
216 |
TPtr newMediaItemTitleDes = iNewMediaItemTitle->Des(); |
|
217 |
||
218 |
CGlxTextEntryPopup* dialog = CGlxTextEntryPopup::NewL(*mediaPopupTitle, newMediaItemTitleDes); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
219 |
|
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
220 |
|
60 | 221 |
if(dialog->ExecuteLD() == EEikBidOk) |
222 |
{ |
|
223 |
command = TGlxCommandFactory::AddContainerCommandLC(*iNewMediaItemTitle, path->Id(0)); |
|
224 |
CleanupStack::Pop(command); |
|
225 |
} |
|
226 |
else |
|
227 |
{ |
|
228 |
iNewMediaCreationError = KErrCancel; |
|
229 |
} |
|
230 |
||
231 |
CleanupStack::PopAndDestroy(mediaPopupTitle); |
|
232 |
CleanupStack::PopAndDestroy(path); |
|
233 |
return command; |
|
234 |
} |
|
235 |
||
236 |
||
237 |
// --------------------------------------------------------------------------- |
|
238 |
// CGlxCommandHandlerNewMedia::HandleErrorL |
|
239 |
// --------------------------------------------------------------------------- |
|
240 |
// |
|
241 |
void CGlxCommandHandlerNewMedia::HandleErrorL(TInt aError) |
|
242 |
{ |
|
243 |
TRACER("CGlxCommandHandlerNewMedia::HandleErrorL"); |
|
244 |
if (aError == KErrAlreadyExists && iNewMediaItemTitle) |
|
245 |
{ |
|
246 |
HBufC* info = StringLoader::LoadLC(R_GLX_NAME_ALREADY_USED, *iNewMediaItemTitle); |
|
247 |
GlxGeneralUiUtilities::ShowInfoNoteL(*info, ETrue); |
|
248 |
CleanupStack::PopAndDestroy(info); |
|
249 |
iFileNameAlreadyExists = ETrue ; |
|
250 |
// As the new Item name already existing , re-execute the command to show entry pop-up |
|
251 |
CGlxMpxCommandCommandHandler::ExecuteL( EGlxCmdAddMedia ); |
|
252 |
if (iSchedulerWait && iNewMediaCreationError == KErrCancel ) |
|
253 |
{ |
|
254 |
// if iSchedulerWait exists then we know the command is being executed from |
|
255 |
// the ExecuteLD() method. |
|
256 |
// Stop the schedulerwait loop if dialog is cancelled after starting the schedulerwait loop |
|
257 |
iSchedulerWait->AsyncStop(); |
|
258 |
} |
|
259 |
} |
|
260 |
else |
|
261 |
{ |
|
262 |
// Use default error handler |
|
263 |
CGlxMpxCommandCommandHandler::HandleErrorL(aError); |
|
264 |
} |
|
265 |
} |
|
266 |
||
267 |
// ----------------------------------------------------------------------------- |
|
268 |
// BypassFiltersForExecute |
|
269 |
// ----------------------------------------------------------------------------- |
|
270 |
// |
|
271 |
EXPORT_C TBool CGlxCommandHandlerNewMedia::BypassFiltersForExecute() const |
|
272 |
{ |
|
273 |
TRACER("CGlxCommandHandlerNewMedia::BypassFiltersForExecute()"); |
|
274 |
// if iSchedulerWait exists then we know the command is being executed from |
|
275 |
// the ExecuteLD() method and filtering is not required. |
|
276 |
return iSchedulerWait != NULL; |
|
277 |
} |
|
278 |
||
279 |
||
280 |
// --------------------------------------------------------------------------- |
|
281 |
// TitlesL fetches the 'media popup title' and 'default new media item title' |
|
282 |
// from the collection. |
|
283 |
// --------------------------------------------------------------------------- |
|
284 |
// |
|
285 |
||
286 |
void CGlxCommandHandlerNewMedia::TitlesL(const TGlxMediaId aCollectionId, |
|
287 |
TDes& aDefaultNewMediaItemTitle) const |
|
288 |
{ |
|
289 |
TRACER("CGlxCommandHandlerNewMedia::TitlesL"); |
|
290 |
CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
291 |
CleanupStack::PushL(path); |
|
292 |
MGlxMediaList* rootList = MGlxMediaList::InstanceL(*path); |
|
293 |
CleanupClosePushL(*rootList); |
|
294 |
||
295 |
TGlxSpecificIdIterator iter(KGlxIdSpaceIdRoot, aCollectionId); |
|
296 |
CGlxAttributeContext* attributeContext = |
|
297 |
new (ELeave) CGlxAttributeContext(&iter); |
|
298 |
CleanupStack::PushL(attributeContext); |
|
299 |
attributeContext->AddAttributeL( |
|
300 |
KGlxMediaCollectionPluginSpecificDefaultMediaTitle); |
|
301 |
rootList->AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
|
302 |
||
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
303 |
TGlxFetchContextRemover contextRemover(attributeContext, *rootList); |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
304 |
// put to cleanupstack as cleanupstack is emptied before stack objects |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
305 |
// are deleted |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
306 |
CleanupClosePushL(contextRemover); |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
307 |
User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
308 |
*rootList, ETrue)); |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
309 |
// context off the list |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
310 |
CleanupStack::PopAndDestroy(&contextRemover); |
60 | 311 |
|
312 |
TInt index = rootList->Index(KGlxIdSpaceIdRoot, aCollectionId); |
|
313 |
||
314 |
__ASSERT_DEBUG(index != KErrNotFound, Panic(EGlxPanicRequiredItemNotFound)); |
|
315 |
||
316 |
TGlxMedia item = rootList->Item(index); |
|
317 |
||
318 |
const CGlxMedia* media = item.Properties(); |
|
319 |
if (media) |
|
320 |
{ |
|
321 |
aDefaultNewMediaItemTitle.Copy(media->ValueText( |
|
322 |
KGlxMediaCollectionPluginSpecificDefaultMediaTitle).Left( |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
323 |
KMaxMediaPopupTitleLength)); |
60 | 324 |
} |
325 |
||
326 |
CleanupStack::PopAndDestroy(attributeContext); |
|
327 |
CleanupStack::PopAndDestroy(rootList); |
|
328 |
CleanupStack::PopAndDestroy(path); |
|
329 |
} |
|
330 |
||
331 |
// --------------------------------------------------------------------------- |
|
332 |
// TitlesL fetches the 'media popup title' and 'default new media item title' |
|
333 |
// from the collection. |
|
334 |
// --------------------------------------------------------------------------- |
|
335 |
// |
|
336 |
HBufC* CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL( |
|
337 |
const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const |
|
338 |
{ |
|
339 |
TRACER("CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL"); |
|
340 |
TGlxSequentialIterator iter; |
|
341 |
CGlxAttributeContext* attributeContext = |
|
342 |
new (ELeave) CGlxAttributeContext(&iter); |
|
343 |
CleanupStack::PushL(attributeContext); |
|
344 |
attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
|
345 |
aList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
|
346 |
TGlxFetchContextRemover contextRemover(attributeContext, aList); |
|
347 |
// put to cleanupstack as cleanupstack is emptied before stack objects |
|
348 |
// are deleted |
|
349 |
CleanupClosePushL(contextRemover); |
|
350 |
User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, |
|
351 |
aList, EFalse)); |
|
352 |
// context off the list |
|
353 |
CleanupStack::PopAndDestroy(&contextRemover); |
|
354 |
CleanupStack::PopAndDestroy(attributeContext); |
|
355 |
||
356 |
RArray<TInt> numbers; |
|
357 |
CleanupClosePushL(numbers); |
|
358 |
||
359 |
TInt count = aList.Count(); |
|
360 |
for (TInt i = 0; i < count; i++) |
|
361 |
{ |
|
362 |
TGlxMedia item = aList.Item(i); |
|
363 |
const CGlxMedia* media = item.Properties(); |
|
364 |
if (media) |
|
365 |
{ |
|
366 |
const TDesC& title = media->ValueText(KMPXMediaGeneralTitle); |
|
367 |
||
368 |
TInt length = aDefaultNewMediaItemTitle.Length(); |
|
369 |
if (title.Left(length).Compare(aDefaultNewMediaItemTitle) == 0) |
|
370 |
{ |
|
371 |
if (length == title.Length()) |
|
372 |
{ |
|
373 |
numbers.InsertInOrderL(0); // special case |
|
374 |
} |
|
375 |
else if (title.Length() > length + KOpenBracket().Length() |
|
376 |
+ KCloseBracket().Length()) |
|
377 |
{ |
|
378 |
TInt pos = length; |
|
379 |
length = KOpenBracket().Length(); |
|
380 |
||
381 |
if (title.Mid(pos, length).Compare(KOpenBracket) == 0 |
|
382 |
&& title.Right(KCloseBracket().Length()).Compare( |
|
383 |
KCloseBracket) == 0) |
|
384 |
{ |
|
385 |
pos += length; |
|
386 |
length = title.Length() - pos |
|
387 |
- KCloseBracket().Length(); |
|
388 |
if (length > 0) |
|
389 |
{ |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
390 |
TLex lex = title.Mid(pos, length); |
60 | 391 |
TInt val = 0; |
392 |
if (lex.Val(val) == KErrNone) |
|
393 |
{ |
|
394 |
numbers.InsertInOrderL(val); |
|
395 |
} |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
||
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
||
404 |
TInt nextNumber = 0; |
|
405 |
count = numbers.Count(); |
|
406 |
for (TInt i = 0; i < count; i++) |
|
407 |
{ |
|
408 |
if (numbers[i] == nextNumber) |
|
409 |
{ |
|
410 |
nextNumber++; |
|
411 |
} |
|
412 |
else |
|
413 |
{ |
|
414 |
break; |
|
415 |
} |
|
416 |
} |
|
417 |
||
418 |
CleanupStack::PopAndDestroy(&numbers); |
|
419 |
||
420 |
TInt defaultTitleLength = aDefaultNewMediaItemTitle.Length() |
|
421 |
+ KFileNameFormatString().Length() + KCloseBracket().Length() |
|
422 |
+ KMaxNumberLength; |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
423 |
// If the default title length is bigger than KMaxMediaPopupTitleLength, |
60 | 424 |
// make sure we allocate enough space for it. |
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
425 |
TInt titleLength = defaultTitleLength > KMaxMediaPopupTitleLength ? |
60 | 426 |
defaultTitleLength |
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
427 |
: KMaxMediaPopupTitleLength; |
60 | 428 |
HBufC* newMediaItemTitle = HBufC::NewL(titleLength); |
429 |
TPtr newMediaItemTitleDes = newMediaItemTitle->Des(); |
|
430 |
newMediaItemTitleDes.Append(aDefaultNewMediaItemTitle); |
|
431 |
||
432 |
if (nextNumber > 0) |
|
433 |
{ |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
434 |
newMediaItemTitleDes.AppendFormat(KFileNameFormatString, nextNumber); |
60 | 435 |
} |
436 |
else |
|
437 |
{ |
|
438 |
// 0 is a special case, return "New Media", not "New Media (0)" |
|
439 |
} |
|
440 |
||
441 |
return newMediaItemTitle; |
|
442 |
} |
|
443 |
||
444 |
// ----------------------------------------------------------------------------- |
|
445 |
// SetFocusL() |
|
446 |
// ----------------------------------------------------------------------------- |
|
447 |
// |
|
448 |
void CGlxCommandHandlerNewMedia::SetFocusL(TInt aIndex) |
|
449 |
{ |
|
450 |
TRACER("CGlxCommandHandlerNewMedia::SetFocusL"); |
|
451 |
iOkToExit = ETrue; |
|
452 |
MediaList().SetFocusL(NGlxListDefs::EAbsolute, aIndex); |
|
453 |
TryExitL(KErrNone); |
|
454 |
} |
|
455 |
||
456 |
// ----------------------------------------------------------------------------- |
|
457 |
// HandleItemAddedL |
|
458 |
// ----------------------------------------------------------------------------- |
|
459 |
// |
|
460 |
EXPORT_C void CGlxCommandHandlerNewMedia::HandleItemAddedL(TInt aStartIndex, |
|
461 |
TInt aEndIndex, MGlxMediaList* aList) |
|
462 |
{ |
|
463 |
TRACER("CGlxCommandHandlerNewMedia::HandleItemAddedL"); |
|
464 |
if (aList == &MediaList() && iNewMediaId != KGlxCollectionRootId) |
|
465 |
{ |
|
466 |
for (TInt i = aStartIndex; i <= aEndIndex; i++) |
|
467 |
{ |
|
468 |
if (aList->Item(i).Id() == iNewMediaId) |
|
469 |
{ |
|
470 |
// calls CGlxCommandHandlerNewMedia::SetFocusL asynchronously |
|
471 |
iAsyncFocuser->SetFocus(i); |
|
472 |
break; |
|
473 |
} |
|
474 |
} |
|
475 |
} |
|
476 |
} |
|
477 |
||
478 |
// ----------------------------------------------------------------------------- |
|
479 |
// Constructor |
|
480 |
// ----------------------------------------------------------------------------- |
|
481 |
// |
|
482 |
CGlxCommandHandlerNewMedia::CGlxAsyncFocuser:: |
|
483 |
CGlxAsyncFocuser(CGlxCommandHandlerNewMedia* aGlxCommandHandlerNewMedia) |
|
484 |
: CActive(KMaxTInt), iGlxCommandHandlerNewMedia(aGlxCommandHandlerNewMedia) |
|
485 |
// The active object has the maximum possible priority to prevent |
|
486 |
// other active objects running before it. (Unless they too are |
|
487 |
// scheduled to run and have the maximum possible priority |
|
488 |
{ |
|
489 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::CGlxAsyncFocuser"); |
|
490 |
__ASSERT_DEBUG(aGlxCommandHandlerNewMedia, Panic(EGlxPanicNullPointer)); |
|
491 |
CActiveScheduler::Add(this); |
|
492 |
} |
|
493 |
||
494 |
// ----------------------------------------------------------------------------- |
|
495 |
// Destructor |
|
496 |
// ----------------------------------------------------------------------------- |
|
497 |
// |
|
498 |
CGlxCommandHandlerNewMedia::CGlxAsyncFocuser:: |
|
499 |
~CGlxAsyncFocuser() |
|
500 |
{ |
|
501 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::~CGlxAsyncFocuser()"); |
|
502 |
Cancel(); |
|
503 |
} |
|
504 |
||
505 |
// ----------------------------------------------------------------------------- |
|
506 |
// RunL |
|
507 |
// ----------------------------------------------------------------------------- |
|
508 |
// |
|
509 |
void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL() |
|
510 |
{ |
|
511 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL()"); |
|
512 |
iGlxCommandHandlerNewMedia->SetFocusL(iFocusIndex); |
|
513 |
} |
|
514 |
||
515 |
// ----------------------------------------------------------------------------- |
|
516 |
// DoCancel |
|
517 |
// ----------------------------------------------------------------------------- |
|
518 |
// |
|
519 |
void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::DoCancel() |
|
520 |
{ |
|
521 |
// No need to do anything |
|
522 |
// CActive::Cancel() will wait for the request to complete |
|
523 |
} |
|
524 |
||
525 |
// ----------------------------------------------------------------------------- |
|
526 |
// SetFocusL |
|
527 |
// ----------------------------------------------------------------------------- |
|
528 |
// |
|
529 |
void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus(TInt aIndex) |
|
530 |
{ |
|
531 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus()"); |
|
532 |
iFocusIndex = aIndex; |
|
533 |
TRequestStatus* requestStatus = &iStatus; |
|
534 |
User::RequestComplete(requestStatus,KErrNone); |
|
535 |
SetActive(); |
|
536 |
} |