64
|
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: Symbian specific functions in optional components selection dialog
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QList>
|
|
19 |
#include <QVariant>
|
|
20 |
#include <s32mem.h> // RDesWriteStream
|
|
21 |
|
|
22 |
const TInt KBufferGranularity = 4;
|
|
23 |
|
|
24 |
|
|
25 |
// ----------------------------------------------------------------------------
|
|
26 |
// ConvertOptionalComponentIndexesL()
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
//
|
|
29 |
QByteArray ConvertOptionalComponentIndexesL( const QList<QVariant> &aIndexes )
|
|
30 |
{
|
|
31 |
// Get aIndexes into symbianArray
|
|
32 |
RArray<TInt> symbianArray;
|
|
33 |
CleanupClosePushL( symbianArray );
|
|
34 |
QListIterator<QVariant> iter( aIndexes );
|
|
35 |
while( iter.hasNext() ) {
|
|
36 |
QVariant item = iter.next();
|
|
37 |
int i;
|
|
38 |
bool ok;
|
|
39 |
i = item.toInt( &ok );
|
|
40 |
if( ok ) {
|
|
41 |
symbianArray.AppendL( i );
|
|
42 |
}
|
|
43 |
}
|
|
44 |
|
|
45 |
// Write symbianArray to a package buffer
|
|
46 |
CBufFlat* buffer = CBufFlat::NewL( KBufferGranularity );
|
|
47 |
CleanupStack::PushL( buffer );
|
|
48 |
RBufWriteStream writeStream( *buffer );
|
|
49 |
CleanupClosePushL( writeStream );
|
|
50 |
TPckg< const RArray<TInt> > indexesPckg( symbianArray );
|
|
51 |
writeStream.WriteL( indexesPckg );
|
|
52 |
writeStream.CommitL();
|
|
53 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
54 |
|
|
55 |
// Create byte array (copies data) from the package buffer
|
|
56 |
const TInt KFromTheBeginning = 0;
|
|
57 |
TPtr8 ptr = buffer->Ptr(KFromTheBeginning);
|
|
58 |
QByteArray byteArray( reinterpret_cast<const char*>( ptr.Ptr() ), ptr.Length() );
|
|
59 |
CleanupStack::PopAndDestroy( buffer );
|
|
60 |
|
|
61 |
CleanupStack::PopAndDestroy( &symbianArray );
|
|
62 |
return byteArray;
|
|
63 |
}
|
|
64 |
|