33
|
1 |
/*
|
|
2 |
* Copyright (c) 2004 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: DM DevDetail Adapter Source Code, WINSCW implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include "nsmldmdevdetailadapter.h"
|
|
23 |
#include "nsmldebug.h"
|
|
24 |
|
|
25 |
// CONSTANTS
|
|
26 |
_LIT( KNSmlDevDetailSwVFile, "z:\\Resource\\DevMan\\DevDetail_SwV.txt" );
|
|
27 |
_LIT( KNSmlDevDetailHwVFile, "z:\\Resource\\DevMan\\DevDetail_HwV.txt" );
|
|
28 |
|
|
29 |
const TInt KNSmlDevDetailMaxDataSize = 2048;
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// CNSmlDmDevDetailAdapter::GetDevDetailDataL( )
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
void CNSmlDmDevDetailAdapter::GetDevDetailDataL(
|
|
35 |
CBufBase& aObject,
|
|
36 |
TNSmlDevDetailData aElement ) const
|
|
37 |
{
|
|
38 |
_DBG_FILE("CNSmlDmDevDetailAdapter::GetDevDetailDataL(): begin (WINSCW)");
|
|
39 |
|
|
40 |
// Select file according to aElement
|
|
41 |
HBufC* name = NULL;
|
|
42 |
|
|
43 |
switch( aElement )
|
|
44 |
{
|
|
45 |
case ESwVersion:
|
|
46 |
name = KNSmlDevDetailSwVFile().AllocLC();
|
|
47 |
break;
|
|
48 |
case EHwVersion:
|
|
49 |
name = KNSmlDevDetailHwVFile().AllocLC();
|
|
50 |
break;
|
|
51 |
default:
|
|
52 |
User::Panic( KNSmlDevDetailPanic, KErrArgument );
|
|
53 |
}
|
|
54 |
|
|
55 |
// open file server session
|
|
56 |
RFs fileSession;
|
|
57 |
User::LeaveIfError( fileSession.Connect() );
|
|
58 |
CleanupClosePushL( fileSession );
|
|
59 |
|
|
60 |
// open file
|
|
61 |
RFile file;
|
|
62 |
TInt err = file.Open( fileSession, *name, EFileRead|EFileShareReadersOnly );
|
|
63 |
|
|
64 |
// if opening file succeeded, read the contents of the file
|
|
65 |
if ( err == KErrNone )
|
|
66 |
{
|
|
67 |
CleanupClosePushL( file );
|
|
68 |
|
|
69 |
// read only if data size is not too large
|
|
70 |
TInt fileSize = 0;
|
|
71 |
User::LeaveIfError( file.Size( fileSize ) );
|
|
72 |
if ( fileSize <= KNSmlDevDetailMaxDataSize )
|
|
73 |
{
|
|
74 |
// read data
|
|
75 |
HBufC8* data = HBufC8::NewLC( fileSize );
|
|
76 |
TPtr8 dataPtr = data->Des();
|
|
77 |
file.Read( dataPtr, fileSize );
|
|
78 |
|
|
79 |
// insert data to result buffer
|
|
80 |
aObject.Reset();
|
|
81 |
aObject.InsertL( 0, *data );
|
|
82 |
|
|
83 |
CleanupStack::PopAndDestroy( data );
|
|
84 |
}
|
|
85 |
|
|
86 |
CleanupStack::PopAndDestroy( &file );
|
|
87 |
}
|
|
88 |
|
|
89 |
CleanupStack::PopAndDestroy( &fileSession );
|
|
90 |
CleanupStack::PopAndDestroy( name );
|
|
91 |
|
|
92 |
_DBG_FILE("CNSmlDmDevDetailAdapter::GetDevDetailDataL(): end (WINSCW)");
|
|
93 |
}
|
|
94 |
|